Added background image color support. Changed "transparency" to "alpha" for layouts. Fixed code syling.

This commit is contained in:
emb
2015-01-02 09:23:49 -06:00
parent ccdafb0e8f
commit d309c3b96f
20 changed files with 195 additions and 78 deletions

View File

@@ -10,20 +10,20 @@
<menu imageType="title" algorithm="easeincircular" x="center" y="center" xOrigin="center" yOrigin="center" speed="0.05" acceleration="0.05" height="25"> <menu imageType="title" algorithm="easeincircular" x="center" y="center" xOrigin="center" yOrigin="center" speed="0.05" acceleration="0.05" height="25">
<!-- todo: the menu does not support the standard onEnter onExit, onHighlightEnter onHighlightExit tags like the rest of the system does. --> <!-- todo: the menu does not support the standard onEnter onExit, onHighlightEnter onHighlightExit tags like the rest of the system does. -->
<item xOffset="-500" yOffset="0" layer="1" fontSize="5" height="0" transparency="0" /> <item xOffset="-500" yOffset="0" layer="1" fontSize="5" height="0" alpha="0" />
<item xOffset="-650" yOffset="200" layer="2" fontSize="7" height="30" transparency="0.1"/> <item xOffset="-650" yOffset="200" layer="2" fontSize="7" height="30" alpha="0.1"/>
<item xOffset="-700" yOffset="300" layer="3" fontSize="10" height="60" transparency="0.25"/> <item xOffset="-700" yOffset="300" layer="3" fontSize="10" height="60" alpha="0.25"/>
<item xOffset="-500" yOffset="350" layer="4" fontSize="20" height="100" transparency="0.5"/> <item xOffset="-500" yOffset="350" layer="4" fontSize="20" height="100" alpha="0.5"/>
<item xOffset="0" yOffset="375" layer="5" fontSize="40" height="200" transparency="1" selected="true" /> <item xOffset="0" yOffset="375" layer="5" fontSize="40" height="200" alpha="1" selected="true" />
<item xOffset="500" yOffset="350" layer="4" fontSize="20" height="100" transparency="0.5"/> <item xOffset="500" yOffset="350" layer="4" fontSize="20" height="100" alpha="0.5"/>
<item xOffset="700" yOffset="300" layer="3" fontSize="10" height="60" transparency="0.25"/> <item xOffset="700" yOffset="300" layer="3" fontSize="10" height="60" alpha="0.25"/>
<item xOffset="650" yOffset="200" layer="2" fontSize="7" height="30" transparency="0.1"/> <item xOffset="650" yOffset="200" layer="2" fontSize="7" height="30" alpha="0.1"/>
<item xOffset="500" yOffset="1" layer="1" fontSize="5" height="0" transparency="0"/> <item xOffset="500" yOffset="1" layer="1" fontSize="5" height="0" alpha="0"/>
</menu> </menu>
<image x="center" y="center" height="stretch" width="stretch" xOrigin="center" yOrigin="center" src="background.png" layer="0" transparency="0.5"/> <image x="center" y="center" height="stretch" width="stretch" xOrigin="center" yOrigin="center" src="background.png" layer="0" alpha="0.5"/>
<image x="30" y="20" height="80" src="logo.png" layer="1" transparency="0.3"> <image x="30" y="20" height="80" src="logo.png" layer="1" alpha="0.3">
<onEnter> <onEnter>
<set duration=".5"> <set duration=".5">
<animate type="y" from="top" to="20" algorithm="easeinquadratic"/> <animate type="y" from="top" to="20" algorithm="easeinquadratic"/>
@@ -97,24 +97,24 @@
<set duration=".2"> <set duration=".2">
<animate type="y" from="bottom" to="100" algorithm="easeinoutquadratic"/> <animate type="y" from="bottom" to="100" algorithm="easeinoutquadratic"/>
<animate type="width" from="0" to="400" algorithm="easeoutquadratic"/> <animate type="width" from="0" to="400" algorithm="easeoutquadratic"/>
<animate type="transparency" from="0" to="0.5" algorithm="easeinquadratic"/> <animate type="alpha" from="0" to="0.5" algorithm="easeinquadratic"/>
</set> </set>
<set duration=".2"> <set duration=".2">
<animate type="y" from="100" to="130" algorithm="easeinoutquadratic"/> <animate type="y" from="100" to="130" algorithm="easeinoutquadratic"/>
<animate type="width" from="400" to="800" algorithm="easeoutquadratic"/> <animate type="width" from="400" to="800" algorithm="easeoutquadratic"/>
<animate type="transparency" from=".5" to="0.75" algorithm="easeinquadratic"/> <animate type="alpha" from=".5" to="0.75" algorithm="easeinquadratic"/>
</set> </set>
</onHighlightEnter> </onHighlightEnter>
<onHighlightExit> <onHighlightExit>
<set duration=".2"> <set duration=".2">
<animate type="y" to="100" from="130" algorithm="easeinoutquadratic"/> <animate type="y" to="100" from="130" algorithm="easeinoutquadratic"/>
<animate type="width" to="400" from="800" algorithm="easeoutquadratic"/> <animate type="width" to="400" from="800" algorithm="easeoutquadratic"/>
<animate type="transparency" from=".75" to="0.5" algorithm="easeinquadratic"/> <animate type="alpha" from=".75" to="0.5" algorithm="easeinquadratic"/>
</set> </set>
<set duration=".2"> <set duration=".2">
<animate type="y" to="bottom" from="100" algorithm="easeinoutquadratic"/> <animate type="y" to="bottom" from="100" algorithm="easeinoutquadratic"/>
<animate type="width" to="0" from="400" algorithm="easeoutquadratic"/> <animate type="width" to="0" from="400" algorithm="easeoutquadratic"/>
<animate type="transparency" to="0.5" from="0" algorithm="easeinquadratic"/> <animate type="alpha" to="0.5" from="0" algorithm="easeinquadratic"/>
</set> </set>
</onHighlightExit> </onHighlightExit>

View File

@@ -10,20 +10,20 @@
<menu imageType="title" algorithm="easeincircular" x="center" y="center" xOrigin="center" yOrigin="center" speed="0.05" acceleration="0.05" height="25"> <menu imageType="title" algorithm="easeincircular" x="center" y="center" xOrigin="center" yOrigin="center" speed="0.05" acceleration="0.05" height="25">
<!-- todo: the menu does not support the standard onEnter onExit, onHighlightEnter onHighlightExit tags like the rest of the system does. --> <!-- todo: the menu does not support the standard onEnter onExit, onHighlightEnter onHighlightExit tags like the rest of the system does. -->
<item xOffset="-100" yOffset="-120" layer="1" fontSize="5" height="15" transparency="0" /> <item xOffset="-100" yOffset="-120" layer="1" fontSize="5" height="15" alpha="0" />
<item xOffset="-250" yOffset="-80" layer="2" fontSize="7" height="20" transparency="0.1"/> <item xOffset="-250" yOffset="-80" layer="2" fontSize="7" height="20" alpha="0.1"/>
<item xOffset="-400" yOffset="0" layer="3" fontSize="10" height="30" transparency="0.25"/> <item xOffset="-400" yOffset="0" layer="3" fontSize="10" height="30" alpha="0.25"/>
<item xOffset="-300" yOffset="133" layer="4" fontSize="20" height="60" transparency="0.5"/> <item xOffset="-300" yOffset="133" layer="4" fontSize="20" height="60" alpha="0.5"/>
<item xOffset="0" yOffset="175" layer="5" fontSize="40" height="150" transparency="1" selected="true" /> <item xOffset="0" yOffset="175" layer="5" fontSize="40" height="150" alpha="1" selected="true" />
<item xOffset="300" yOffset="133" layer="4" fontSize="20" height="60" transparency="0.5"/> <item xOffset="300" yOffset="133" layer="4" fontSize="20" height="60" alpha="0.5"/>
<item xOffset="400" yOffset="0" layer="3" fontSize="10" height="30" transparency="0.25"/> <item xOffset="400" yOffset="0" layer="3" fontSize="10" height="30" alpha="0.25"/>
<item xOffset="250" yOffset="-80" layer="2" fontSize="7" height="15" transparency="0.1"/> <item xOffset="250" yOffset="-80" layer="2" fontSize="7" height="15" alpha="0.1"/>
<item xOffset="100" yOffset="-120" layer="1" fontSize="5" height="0" transparency="0"/> <item xOffset="100" yOffset="-120" layer="1" fontSize="5" height="0" alpha="0"/>
</menu> </menu>
<image x="center" y="center" height="stretch" width="stretch" xOrigin="center" yOrigin="center" src="background.png" layer="0" transparency="0.5"/> <image x="center" y="center" height="stretch" width="stretch" xOrigin="center" yOrigin="center" src="background.png" layer="0" alpha="0.5"/>
<image x="30" y="20" height="50" src="logo.png" layer="1" transparency="0.3"> <image x="30" y="20" height="50" src="logo.png" layer="1" alpha="0.3">
<onEnter> <onEnter>
<set duration=".5"> <set duration=".5">
<animate type="y" from="top" to="20" algorithm="easeinquadratic"/> <animate type="y" from="top" to="20" algorithm="easeinquadratic"/>
@@ -59,24 +59,24 @@
<set duration=".2"> <set duration=".2">
<animate type="y" from="bottom" to="100" algorithm="easeinoutquadratic"/> <animate type="y" from="bottom" to="100" algorithm="easeinoutquadratic"/>
<animate type="width" from="0" to="200" algorithm="easeoutquadratic"/> <animate type="width" from="0" to="200" algorithm="easeoutquadratic"/>
<animate type="transparency" from="0" to="0.5" algorithm="easeinquadratic"/> <animate type="alpha" from="0" to="0.5" algorithm="easeinquadratic"/>
</set> </set>
<set duration=".2"> <set duration=".2">
<animate type="y" from="100" to="130" algorithm="easeinoutquadratic"/> <animate type="y" from="100" to="130" algorithm="easeinoutquadratic"/>
<animate type="width" from="200" to="320" algorithm="easeoutquadratic"/> <animate type="width" from="200" to="320" algorithm="easeoutquadratic"/>
<animate type="transparency" from=".5" to="0.75" algorithm="easeinquadratic"/> <animate type="alpha" from=".5" to="0.75" algorithm="easeinquadratic"/>
</set> </set>
</onHighlightEnter> </onHighlightEnter>
<onHighlightExit> <onHighlightExit>
<set duration=".2"> <set duration=".2">
<animate type="y" to="100" from="130" algorithm="easeinoutquadratic"/> <animate type="y" to="100" from="130" algorithm="easeinoutquadratic"/>
<animate type="width" to="200" from="320" algorithm="easeoutquadratic"/> <animate type="width" to="200" from="320" algorithm="easeoutquadratic"/>
<animate type="transparency" from=".75" to="0.5" algorithm="easeinquadratic"/> <animate type="alpha" from=".75" to="0.5" algorithm="easeinquadratic"/>
</set> </set>
<set duration=".2"> <set duration=".2">
<animate type="y" to="bottom" from="100" algorithm="easeinoutquadratic"/> <animate type="y" to="bottom" from="100" algorithm="easeinoutquadratic"/>
<animate type="width" to="0" from="200" algorithm="easeoutquadratic"/> <animate type="width" to="0" from="200" algorithm="easeoutquadratic"/>
<animate type="transparency" to="0.5" from="0" algorithm="easeinquadratic"/> <animate type="alpha" to="0.5" from="0" algorithm="easeinquadratic"/>
</set> </set>
</onHighlightExit> </onHighlightExit>

View File

@@ -5,10 +5,10 @@
#include "../Graphics/Page.h" #include "../Graphics/Page.h"
AttractMode::AttractMode() AttractMode::AttractMode()
: IsActive(false) : IsActive(false)
, ElapsedTime(0) , ElapsedTime(0)
, ActiveTime(0) , ActiveTime(0)
, IdleTime(0) , IdleTime(0)
{ {
} }

View File

@@ -34,7 +34,7 @@ bool Tween::GetTweenProperty(std::string name, TweenProperty &property)
TweenPropertyMap["x"] = TWEEN_PROPERTY_X; TweenPropertyMap["x"] = TWEEN_PROPERTY_X;
TweenPropertyMap["y"] = TWEEN_PROPERTY_Y; TweenPropertyMap["y"] = TWEEN_PROPERTY_Y;
TweenPropertyMap["angle"] = TWEEN_PROPERTY_ANGLE; TweenPropertyMap["angle"] = TWEEN_PROPERTY_ANGLE;
TweenPropertyMap["transparency"] = TWEEN_PROPERTY_TRANSPARENCY; TweenPropertyMap["alpha"] = TWEEN_PROPERTY_ALPHA;
TweenPropertyMap["width"] = TWEEN_PROPERTY_WIDTH; TweenPropertyMap["width"] = TWEEN_PROPERTY_WIDTH;
TweenPropertyMap["height"] = TWEEN_PROPERTY_HEIGHT; TweenPropertyMap["height"] = TWEEN_PROPERTY_HEIGHT;
TweenPropertyMap["xorigin"] = TWEEN_PROPERTY_X_ORIGIN; TweenPropertyMap["xorigin"] = TWEEN_PROPERTY_X_ORIGIN;

View File

@@ -34,7 +34,7 @@ enum TweenProperty
TWEEN_PROPERTY_HEIGHT, TWEEN_PROPERTY_HEIGHT,
TWEEN_PROPERTY_WIDTH, TWEEN_PROPERTY_WIDTH,
TWEEN_PROPERTY_ANGLE, TWEEN_PROPERTY_ANGLE,
TWEEN_PROPERTY_TRANSPARENCY, TWEEN_PROPERTY_ALPHA,
TWEEN_PROPERTY_X, TWEEN_PROPERTY_X,
TWEEN_PROPERTY_Y, TWEEN_PROPERTY_Y,
TWEEN_PROPERTY_X_ORIGIN, TWEEN_PROPERTY_X_ORIGIN,

View File

@@ -5,6 +5,7 @@
#include "../Animate/Tween.h" #include "../Animate/Tween.h"
#include "../../Graphics/ViewInfo.h" #include "../../Graphics/ViewInfo.h"
#include "../../Utility/Log.h" #include "../../Utility/Log.h"
#include "../../SDL.h"
Component::Component() Component::Component()
{ {
@@ -15,8 +16,8 @@ Component::Component()
OnHighlightExitTweens = NULL; OnHighlightExitTweens = NULL;
SelectedItem = NULL; SelectedItem = NULL;
NewItemSelectedSinceEnter = false; NewItemSelectedSinceEnter = false;
BackgroundTexture = NULL;
FreeGraphicsMemory(); FreeGraphicsMemory();
} }
Component::~Component() Component::~Component()
@@ -34,11 +35,27 @@ void Component::FreeGraphicsMemory()
CurrentTweens = NULL; CurrentTweens = NULL;
CurrentTweenIndex = 0; CurrentTweenIndex = 0;
CurrentTweenComplete = false; CurrentTweenComplete = false;
ElapsedTweenTime =0; ElapsedTweenTime = 0;
ScrollActive = false; ScrollActive = false;
if(BackgroundTexture)
{
SDL_DestroyTexture(BackgroundTexture);
BackgroundTexture = NULL;
}
} }
void Component::AllocateGraphicsMemory() void Component::AllocateGraphicsMemory()
{ {
if(!BackgroundTexture)
{
// make a 4x4 pixel wide surface to be stretched during rendering, make it a white background so we can use
// color later
SDL_Surface *surface = SDL_CreateRGBSurface(0, 4, 4, 32, 0, 0, 0, 0);
SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, 255, 255, 255));
BackgroundTexture = SDL_CreateTextureFromSurface(SDL::GetRenderer(), surface);
SDL_FreeSurface(surface);
SDL_SetTextureBlendMode(BackgroundTexture, SDL_BLENDMODE_BLEND);
}
} }
void Component::TriggerEnterEvent() void Component::TriggerEnterEvent()
@@ -72,8 +89,6 @@ bool Component::IsWaiting()
return (CurrentAnimationState == HIGHLIGHT_WAIT); return (CurrentAnimationState == HIGHLIGHT_WAIT);
} }
void Component::Update(float dt) void Component::Update(float dt)
{ {
ElapsedTweenTime += dt; ElapsedTweenTime += dt;
@@ -184,6 +199,22 @@ void Component::Update(float dt)
CurrentTweenComplete = Animate(IsIdle()); CurrentTweenComplete = Animate(IsIdle());
} }
void Component::Draw()
{
ViewInfo *info = GetBaseViewInfo();
SDL_Rect rect;
rect.h = static_cast<int>(info->GetHeight());
rect.w = static_cast<int>(info->GetWidth());
rect.x = static_cast<int>(info->GetXRelativeToOrigin());
rect.y = static_cast<int>(info->GetYRelativeToOrigin());
SDL_SetTextureColorMod(BackgroundTexture,
static_cast<char>(info->GetBackgroundRed()*255),
static_cast<char>(info->GetBackgroundGreen()*255),
static_cast<char>(info->GetBackgroundBlue()*255));
SDL::RenderCopy(BackgroundTexture, static_cast<char>(info->GetBackgroundAlpha()*255), NULL, &rect, info->GetAngle());
}
bool Component::Animate(bool loop) bool Component::Animate(bool loop)
{ {
@@ -236,8 +267,8 @@ bool Component::Animate(bool loop)
GetBaseViewInfo()->SetAngle(value); GetBaseViewInfo()->SetAngle(value);
break; break;
case TWEEN_PROPERTY_TRANSPARENCY: case TWEEN_PROPERTY_ALPHA:
GetBaseViewInfo()->SetTransparency(value); GetBaseViewInfo()->SetAlpha(value);
break; break;
case TWEEN_PROPERTY_X_ORIGIN: case TWEEN_PROPERTY_X_ORIGIN:

View File

@@ -5,6 +5,7 @@
#include <vector> #include <vector>
#include "../../SDL.h"
#include "../MenuNotifierInterface.h" #include "../MenuNotifierInterface.h"
#include "../ViewInfo.h" #include "../ViewInfo.h"
#include "../Animate/Tween.h" #include "../Animate/Tween.h"
@@ -53,7 +54,7 @@ public:
} }
virtual void Update(float dt); virtual void Update(float dt);
virtual void Draw() = 0; virtual void Draw();
ViewInfo *GetBaseViewInfo() ViewInfo *GetBaseViewInfo()
{ {
@@ -119,4 +120,6 @@ private:
Tween *TweenInst; Tween *TweenInst;
Item *SelectedItem; Item *SelectedItem;
bool ScrollActive; bool ScrollActive;
SDL_Texture *BackgroundTexture;
}; };

View File

@@ -60,6 +60,8 @@ void Image::AllocateGraphicsMemory()
void Image::Draw() void Image::Draw()
{ {
Component::Draw();
if(Texture) if(Texture)
{ {
ViewInfo *info = GetBaseViewInfo(); ViewInfo *info = GetBaseViewInfo();
@@ -70,6 +72,6 @@ void Image::Draw()
rect.h = static_cast<int>(info->GetHeight()); rect.h = static_cast<int>(info->GetHeight());
rect.w = static_cast<int>(info->GetWidth()); rect.w = static_cast<int>(info->GetWidth());
SDL::RenderCopy(Texture, static_cast<char>((info->GetTransparency() * 255)), NULL, &rect, info->GetAngle()); SDL::RenderCopy(Texture, static_cast<char>((info->GetAlpha() * 255)), NULL, &rect, info->GetAngle());
} }
} }

View File

@@ -162,6 +162,8 @@ void ReloadableMedia::Draw()
{ {
ViewInfo *info = GetBaseViewInfo(); ViewInfo *info = GetBaseViewInfo();
Component::Draw();
if(LoadedComponent) if(LoadedComponent)
{ {
info->SetImageHeight(LoadedComponent->GetBaseViewInfo()->GetImageHeight()); info->SetImageHeight(LoadedComponent->GetBaseViewInfo()->GetImageHeight());

View File

@@ -329,7 +329,7 @@ void ScrollingList::Update(float dt)
spriteViewInfo->SetYOffset(Tween::AnimateSingle(LINEAR, currentViewInfo->GetYOffset(), nextViewInfo->GetYOffset(), scrollPeriod, CurrentAnimateTime)); spriteViewInfo->SetYOffset(Tween::AnimateSingle(LINEAR, currentViewInfo->GetYOffset(), nextViewInfo->GetYOffset(), scrollPeriod, CurrentAnimateTime));
spriteViewInfo->SetHeight(Tween::AnimateSingle(LINEAR, currentViewInfo->GetHeight(), nextViewInfo->GetHeight(), scrollPeriod, CurrentAnimateTime)); spriteViewInfo->SetHeight(Tween::AnimateSingle(LINEAR, currentViewInfo->GetHeight(), nextViewInfo->GetHeight(), scrollPeriod, CurrentAnimateTime));
spriteViewInfo->SetWidth(Tween::AnimateSingle(LINEAR, currentViewInfo->GetWidth(), nextViewInfo->GetWidth(), scrollPeriod, CurrentAnimateTime)); spriteViewInfo->SetWidth(Tween::AnimateSingle(LINEAR, currentViewInfo->GetWidth(), nextViewInfo->GetWidth(), scrollPeriod, CurrentAnimateTime));
spriteViewInfo->SetTransparency(Tween::AnimateSingle(LINEAR, currentViewInfo->GetTransparency(), nextViewInfo->GetTransparency(), scrollPeriod, CurrentAnimateTime)); spriteViewInfo->SetAlpha(Tween::AnimateSingle(LINEAR, currentViewInfo->GetAlpha(), nextViewInfo->GetAlpha(), scrollPeriod, CurrentAnimateTime));
spriteViewInfo->SetAngle(Tween::AnimateSingle(LINEAR, currentViewInfo->GetAngle(), nextViewInfo->GetAngle(), scrollPeriod, CurrentAnimateTime)); spriteViewInfo->SetAngle(Tween::AnimateSingle(LINEAR, currentViewInfo->GetAngle(), nextViewInfo->GetAngle(), scrollPeriod, CurrentAnimateTime));
spriteViewInfo->SetFontSize(Tween::AnimateSingle(LINEAR, currentViewInfo->GetFontSize(), nextViewInfo->GetFontSize(), scrollPeriod, CurrentAnimateTime)); spriteViewInfo->SetFontSize(Tween::AnimateSingle(LINEAR, currentViewInfo->GetFontSize(), nextViewInfo->GetFontSize(), scrollPeriod, CurrentAnimateTime));
c->Update(dt); c->Update(dt);

View File

@@ -36,6 +36,8 @@ void Text::AllocateGraphicsMemory()
void Text::Draw() void Text::Draw()
{ {
Component::Draw();
SDL_Texture *t = FontInst->GetTexture(); SDL_Texture *t = FontInst->GetTexture();
ViewInfo *info = GetBaseViewInfo(); ViewInfo *info = GetBaseViewInfo();
@@ -89,7 +91,7 @@ void Text::Draw()
SDL_SetTextureColorMod(t, FontColor.r, FontColor.g, FontColor.b); SDL_SetTextureColorMod(t, FontColor.r, FontColor.g, FontColor.b);
SDL_UnlockMutex(SDL::GetMutex()); SDL_UnlockMutex(SDL::GetMutex());
SDL::RenderCopy(t, static_cast<char>(info->GetTransparency() * 255), &charRect, &rect, info->GetAngle()); SDL::RenderCopy(t, static_cast<char>(info->GetAlpha() * 255), &charRect, &rect, info->GetAngle());
rect.x += static_cast<int>(glyph.Advance * scale); rect.x += static_cast<int>(glyph.Advance * scale);
} }
} }

View File

@@ -79,6 +79,6 @@ void VideoComponent::Draw()
if(texture) if(texture)
{ {
SDL::RenderCopy(texture, static_cast<int>(info->GetTransparency() * 255), NULL, &rect, info->GetAngle()); SDL::RenderCopy(texture, static_cast<int>(info->GetAlpha() * 255), NULL, &rect, info->GetAngle());
} }
} }

View File

@@ -523,9 +523,11 @@ void PageBuilder::BuildViewInfo(xml_node<> *componentXml, ViewInfo *info)
xml_attribute<> *minWidth = FindRecursiveAttribute(componentXml, "minWidth"); xml_attribute<> *minWidth = FindRecursiveAttribute(componentXml, "minWidth");
xml_attribute<> *maxHeight = FindRecursiveAttribute(componentXml, "maxHeight"); xml_attribute<> *maxHeight = FindRecursiveAttribute(componentXml, "maxHeight");
xml_attribute<> *maxWidth = FindRecursiveAttribute(componentXml, "maxWidth"); xml_attribute<> *maxWidth = FindRecursiveAttribute(componentXml, "maxWidth");
xml_attribute<> *transparency = FindRecursiveAttribute(componentXml, "transparency"); xml_attribute<> *alpha = FindRecursiveAttribute(componentXml, "alpha");
xml_attribute<> *angle = FindRecursiveAttribute(componentXml, "angle"); xml_attribute<> *angle = FindRecursiveAttribute(componentXml, "angle");
xml_attribute<> *layer = FindRecursiveAttribute(componentXml, "layer"); xml_attribute<> *layer = FindRecursiveAttribute(componentXml, "layer");
xml_attribute<> *backgroundColor = FindRecursiveAttribute(componentXml, "backgroundColor");
xml_attribute<> *backgroundAlpha = FindRecursiveAttribute(componentXml, "backgroundAlpha");
info->SetX(GetHorizontalAlignment(x, 0)); info->SetX(GetHorizontalAlignment(x, 0));
info->SetY(GetVerticalAlignment(y, 0)); info->SetY(GetVerticalAlignment(y, 0));
@@ -552,18 +554,37 @@ void PageBuilder::BuildViewInfo(xml_node<> *componentXml, ViewInfo *info)
info->SetWidth(GetHorizontalAlignment(width, -1)); info->SetWidth(GetHorizontalAlignment(width, -1));
} }
info->SetFontSize(GetVerticalAlignment(fontSize, -1)); info->SetFontSize(GetVerticalAlignment(fontSize, -1));
/*
std::stringstream ss;
ss << "font size is \"" << info->GetFontSize() << "\"";
Logger::Write(Logger::ZONE_ERROR, "Layout", ss.str());
*/
info->SetMinHeight(GetVerticalAlignment(minHeight, 0)); info->SetMinHeight(GetVerticalAlignment(minHeight, 0));
info->SetMinWidth(GetHorizontalAlignment(minWidth, 0)); info->SetMinWidth(GetHorizontalAlignment(minWidth, 0));
info->SetMaxHeight(GetVerticalAlignment(maxHeight, FLT_MAX)); info->SetMaxHeight(GetVerticalAlignment(maxHeight, FLT_MAX));
info->SetMaxWidth(GetVerticalAlignment(maxWidth, FLT_MAX)); info->SetMaxWidth(GetVerticalAlignment(maxWidth, FLT_MAX));
info->SetTransparency( transparency ? Utils::ConvertFloat(transparency->value()) : 1); info->SetAlpha( alpha ? Utils::ConvertFloat(alpha->value()) : 1);
info->SetAngle( angle ? Utils::ConvertFloat(angle->value()) : 0); info->SetAngle( angle ? Utils::ConvertFloat(angle->value()) : 0);
info->SetLayer( layer ? Utils::ConvertInt(layer->value()) : 0); info->SetLayer( layer ? Utils::ConvertInt(layer->value()) : 0);
if(backgroundColor)
{
std::stringstream ss(backgroundColor->value());
int num;
ss >> std::hex >> num;
int red = num / 0x10000;
int green = (num / 0x100) % 0x100;
int blue = num % 0x100;
info->SetBackgroundRed(static_cast<float>(red)/255);
info->SetBackgroundGreen(static_cast<float>(green)/255);
info->SetBackgroundBlue(static_cast<float>(blue)/255);
}
if(backgroundAlpha)
{
std::stringstream ss(backgroundAlpha->value());
int num;
ss >> std::hex >> num;
info->SetBackgroundAlpha(static_cast<float>(num)/255);
}
} }

View File

@@ -23,8 +23,12 @@ ViewInfo::ViewInfo()
, ImageHeight(0) , ImageHeight(0)
, FontSize(-1) , FontSize(-1)
, Angle(0) , Angle(0)
, Transparency(1) , Alpha(1)
, Layer(0) , Layer(0)
, BackgroundRed(0)
, BackgroundGreen(0)
, BackgroundBlue(0)
, BackgroundAlpha(0)
{ {
} }
@@ -201,14 +205,14 @@ void ViewInfo::SetMinWidth(float minwidth)
MinWidth = minwidth; MinWidth = minwidth;
} }
float ViewInfo::GetTransparency() const float ViewInfo::GetAlpha() const
{ {
return Transparency; return Alpha;
} }
void ViewInfo::SetTransparency(float transparency) void ViewInfo::SetAlpha(float alpha)
{ {
Transparency = transparency; Alpha = alpha;
} }
float ViewInfo::GetX() const float ViewInfo::GetX() const
@@ -298,3 +302,43 @@ void ViewInfo::SetFontSize(float fontSize)
{ {
FontSize = fontSize; FontSize = fontSize;
} }
float ViewInfo::GetBackgroundRed()
{
return BackgroundRed;
}
void ViewInfo::SetBackgroundRed(float value)
{
BackgroundRed = value;
}
float ViewInfo::GetBackgroundGreen()
{
return BackgroundGreen;
}
void ViewInfo::SetBackgroundGreen(float value)
{
BackgroundGreen = value;
}
float ViewInfo::GetBackgroundBlue()
{
return BackgroundBlue;
}
void ViewInfo::SetBackgroundBlue(float value)
{
BackgroundBlue = value;
}
float ViewInfo::GetBackgroundAlpha()
{
return BackgroundAlpha;
}
void ViewInfo::SetBackgroundAlpha(float value)
{
BackgroundAlpha = value;
}

View File

@@ -35,8 +35,8 @@ public:
void SetMinHeight(float minheight); void SetMinHeight(float minheight);
float GetMinWidth() const; float GetMinWidth() const;
void SetMinWidth(float minwidth); void SetMinWidth(float minwidth);
float GetTransparency() const; float GetAlpha() const;
void SetTransparency(float transparency); void SetAlpha(float alpha);
float GetX() const; float GetX() const;
void SetX(float x); void SetX(float x);
float GetXOffset() const; float GetXOffset() const;
@@ -54,6 +54,15 @@ public:
float GetRawWidth(); float GetRawWidth();
float GetRawHeight(); float GetRawHeight();
float GetBackgroundRed();
void SetBackgroundRed(float value);
float GetBackgroundGreen();
void SetBackgroundGreen(float value);
float GetBackgroundBlue();
void SetBackgroundBlue(float value);
float GetBackgroundAlpha();
void SetBackgroundAlpha(float value);
void SetHeight(float height); void SetHeight(float height);
void SetWidth(float width); void SetWidth(float width);
float GetFontSize() const; float GetFontSize() const;
@@ -82,8 +91,12 @@ private:
float ImageHeight; float ImageHeight;
float FontSize; float FontSize;
float Angle; float Angle;
float Transparency; float Alpha;
unsigned int Layer; unsigned int Layer;
float HorizontalScale; float HorizontalScale;
float VerticalScale; float VerticalScale;
float BackgroundRed;
float BackgroundGreen;
float BackgroundBlue;
float BackgroundAlpha;
}; };

View File

@@ -49,7 +49,7 @@ private:
RETROFE_STATE ProcessUserInput(Page *page); RETROFE_STATE ProcessUserInput(Page *page);
void Update(float dt, bool scrollActive); void Update(float dt, bool scrollActive);
std::string GetLayout(std::string collectionName); std::string GetLayout(std::string collectionName);
std::vector<Item *> *GetCollection(std::string collectionName); std::vector<Item *> *GetCollection(std::string collectionName);
Configuration &Config; Configuration &Config;
CollectionDatabase &CollectionDB; CollectionDatabase &CollectionDB;
UserInput Input; UserInput Input;

View File

@@ -230,8 +230,7 @@ SDL_Window* SDL::GetWindow()
return Window; return Window;
} }
bool SDL::RenderCopy(SDL_Texture *texture, unsigned char alpha, SDL_Rect *src, SDL_Rect *dest, double angle)
bool SDL::RenderCopy(SDL_Texture *texture, unsigned char transparency, SDL_Rect *src, SDL_Rect *dest, double angle)
{ {
SDL_Rect rotateRect; SDL_Rect rotateRect;
rotateRect.w = dest->w; rotateRect.w = dest->w;
@@ -248,7 +247,7 @@ bool SDL::RenderCopy(SDL_Texture *texture, unsigned char transparency, SDL_Rect
rotateRect.y = dest->y; rotateRect.y = dest->y;
} }
SDL_SetTextureAlphaMod(texture, transparency); SDL_SetTextureAlphaMod(texture, alpha);
SDL_RenderCopyEx(GetRenderer(), texture, src, &rotateRect, angle, NULL, SDL_FLIP_NONE); SDL_RenderCopyEx(GetRenderer(), texture, src, &rotateRect, angle, NULL, SDL_FLIP_NONE);
return true; return true;

View File

@@ -15,7 +15,7 @@ public:
static SDL_Renderer *GetRenderer(); static SDL_Renderer *GetRenderer();
static SDL_mutex *GetMutex(); static SDL_mutex *GetMutex();
static SDL_Window *GetWindow(); static SDL_Window *GetWindow();
static bool RenderCopy(SDL_Texture *texture, unsigned char transparency, SDL_Rect *src, SDL_Rect *dest, double angle); static bool RenderCopy(SDL_Texture *texture, unsigned char alpha, SDL_Rect *src, SDL_Rect *dest, double angle);
static int GetWindowWidth() static int GetWindowWidth()
{ {
return WindowWidth; return WindowWidth;