mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-27 18:25:13 +01:00
Making BaseViewInfo public.
This commit is contained in:
parent
5afefc7d47
commit
8f6658dd13
@ -188,14 +188,6 @@ void Component::ForceIdle()
|
||||
CurrentTweens = NULL;
|
||||
}
|
||||
|
||||
ViewInfo *Component::GetBaseViewInfo()
|
||||
{
|
||||
return &BaseViewInfo;
|
||||
}
|
||||
void Component::UpdateBaseViewInfo(ViewInfo &info)
|
||||
{
|
||||
BaseViewInfo = info;
|
||||
}
|
||||
|
||||
bool Component::IsScrollActive() const
|
||||
{
|
||||
@ -378,20 +370,19 @@ void Component::Draw()
|
||||
|
||||
if(BackgroundTexture)
|
||||
{
|
||||
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());
|
||||
rect.h = static_cast<int>(BaseViewInfo.GetHeight());
|
||||
rect.w = static_cast<int>(BaseViewInfo.GetWidth());
|
||||
rect.x = static_cast<int>(BaseViewInfo.GetXRelativeToOrigin());
|
||||
rect.y = static_cast<int>(BaseViewInfo.GetYRelativeToOrigin());
|
||||
|
||||
|
||||
SDL_SetTextureColorMod(BackgroundTexture,
|
||||
static_cast<char>(info->GetBackgroundRed()*255),
|
||||
static_cast<char>(info->GetBackgroundGreen()*255),
|
||||
static_cast<char>(info->GetBackgroundBlue()*255));
|
||||
static_cast<char>(BaseViewInfo.GetBackgroundRed()*255),
|
||||
static_cast<char>(BaseViewInfo.GetBackgroundGreen()*255),
|
||||
static_cast<char>(BaseViewInfo.GetBackgroundBlue()*255));
|
||||
|
||||
SDL::RenderCopy(BackgroundTexture, static_cast<char>(info->GetBackgroundAlpha()*255), NULL, &rect, info->GetAngle());
|
||||
SDL::RenderCopy(BackgroundTexture, static_cast<char>(BaseViewInfo.GetBackgroundAlpha()*255), NULL, &rect, BaseViewInfo.GetAngle());
|
||||
}
|
||||
}
|
||||
|
||||
@ -427,51 +418,51 @@ bool Component::Animate(bool loop)
|
||||
switch(tween->GetProperty())
|
||||
{
|
||||
case TWEEN_PROPERTY_X:
|
||||
GetBaseViewInfo()->SetX(value);
|
||||
BaseViewInfo.SetX(value);
|
||||
break;
|
||||
|
||||
case TWEEN_PROPERTY_Y:
|
||||
GetBaseViewInfo()->SetY(value);
|
||||
BaseViewInfo.SetY(value);
|
||||
break;
|
||||
|
||||
case TWEEN_PROPERTY_HEIGHT:
|
||||
GetBaseViewInfo()->SetHeight(value);
|
||||
BaseViewInfo.SetHeight(value);
|
||||
break;
|
||||
|
||||
case TWEEN_PROPERTY_WIDTH:
|
||||
GetBaseViewInfo()->SetWidth(value);
|
||||
BaseViewInfo.SetWidth(value);
|
||||
break;
|
||||
|
||||
case TWEEN_PROPERTY_ANGLE:
|
||||
GetBaseViewInfo()->SetAngle(value);
|
||||
BaseViewInfo.SetAngle(value);
|
||||
break;
|
||||
|
||||
case TWEEN_PROPERTY_ALPHA:
|
||||
GetBaseViewInfo()->SetAlpha(value);
|
||||
BaseViewInfo.SetAlpha(value);
|
||||
break;
|
||||
|
||||
case TWEEN_PROPERTY_X_ORIGIN:
|
||||
GetBaseViewInfo()->SetXOrigin(value);
|
||||
BaseViewInfo.SetXOrigin(value);
|
||||
break;
|
||||
|
||||
case TWEEN_PROPERTY_Y_ORIGIN:
|
||||
GetBaseViewInfo()->SetYOrigin(value);
|
||||
BaseViewInfo.SetYOrigin(value);
|
||||
break;
|
||||
|
||||
case TWEEN_PROPERTY_X_OFFSET:
|
||||
GetBaseViewInfo()->SetXOffset(value);
|
||||
BaseViewInfo.SetXOffset(value);
|
||||
break;
|
||||
|
||||
case TWEEN_PROPERTY_Y_OFFSET:
|
||||
GetBaseViewInfo()->SetYOffset(value);
|
||||
BaseViewInfo.SetYOffset(value);
|
||||
break;
|
||||
|
||||
case TWEEN_PROPERTY_FONT_SIZE:
|
||||
GetBaseViewInfo()->SetFontSize(value);
|
||||
BaseViewInfo.SetFontSize(value);
|
||||
break;
|
||||
|
||||
case TWEEN_PROPERTY_BACKGROUND_ALPHA:
|
||||
GetBaseViewInfo()->SetBackgroundAlpha(value);
|
||||
BaseViewInfo.SetBackgroundAlpha(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,10 +52,9 @@ public:
|
||||
AnimationEvents *GetTweens();
|
||||
void SetTweens(AnimationEvents *set);
|
||||
void ForceIdle();
|
||||
ViewInfo *GetBaseViewInfo();
|
||||
void UpdateBaseViewInfo(ViewInfo &info);
|
||||
bool IsScrollActive() const;
|
||||
void SetScrollActive(bool scrollActive);
|
||||
ViewInfo BaseViewInfo;
|
||||
|
||||
protected:
|
||||
Item *GetSelectedItem();
|
||||
@ -97,7 +96,6 @@ private:
|
||||
unsigned int CurrentTweenIndex;
|
||||
bool CurrentTweenComplete;
|
||||
std::string CollectionName;
|
||||
ViewInfo BaseViewInfo;
|
||||
float ElapsedTweenTime;
|
||||
bool ScrollActive;
|
||||
};
|
||||
|
||||
@ -62,8 +62,8 @@ void Image::AllocateGraphicsMemory()
|
||||
{
|
||||
SDL_SetTextureBlendMode(Texture, SDL_BLENDMODE_BLEND);
|
||||
SDL_QueryTexture(Texture, NULL, NULL, &width, &height);
|
||||
GetBaseViewInfo()->SetImageWidth(width * ScaleX);
|
||||
GetBaseViewInfo()->SetImageHeight(height * ScaleY);
|
||||
BaseViewInfo.SetImageWidth(width * ScaleX);
|
||||
BaseViewInfo.SetImageHeight(height * ScaleY);
|
||||
}
|
||||
SDL_UnlockMutex(SDL::GetMutex());
|
||||
|
||||
@ -76,14 +76,13 @@ void Image::Draw()
|
||||
|
||||
if(Texture)
|
||||
{
|
||||
ViewInfo *info = GetBaseViewInfo();
|
||||
SDL_Rect rect;
|
||||
|
||||
rect.x = static_cast<int>(info->GetXRelativeToOrigin());
|
||||
rect.y = static_cast<int>(info->GetYRelativeToOrigin());
|
||||
rect.h = static_cast<int>(info->GetHeight());
|
||||
rect.w = static_cast<int>(info->GetWidth());
|
||||
rect.x = static_cast<int>(BaseViewInfo.GetXRelativeToOrigin());
|
||||
rect.y = static_cast<int>(BaseViewInfo.GetYRelativeToOrigin());
|
||||
rect.h = static_cast<int>(BaseViewInfo.GetHeight());
|
||||
rect.w = static_cast<int>(BaseViewInfo.GetWidth());
|
||||
|
||||
SDL::RenderCopy(Texture, static_cast<char>((info->GetAlpha() * 255)), NULL, &rect, info->GetAngle());
|
||||
SDL::RenderCopy(Texture, static_cast<char>((BaseViewInfo.GetAlpha() * 255)), NULL, &rect, BaseViewInfo.GetAngle());
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,10 +83,10 @@ void ReloadableMedia::Update(float dt)
|
||||
{
|
||||
|
||||
// video needs to run a frame to start getting size info
|
||||
if(GetBaseViewInfo()->GetImageHeight() == 0 && GetBaseViewInfo()->GetImageWidth() == 0)
|
||||
if(BaseViewInfo.GetImageHeight() == 0 && BaseViewInfo.GetImageWidth() == 0)
|
||||
{
|
||||
GetBaseViewInfo()->SetImageWidth(LoadedComponent->GetBaseViewInfo()->GetImageWidth());
|
||||
GetBaseViewInfo()->SetImageHeight(LoadedComponent->GetBaseViewInfo()->GetImageHeight());
|
||||
BaseViewInfo.SetImageWidth(LoadedComponent->BaseViewInfo.GetImageWidth());
|
||||
BaseViewInfo.SetImageHeight(LoadedComponent->BaseViewInfo.GetImageHeight());
|
||||
}
|
||||
|
||||
LoadedComponent->Update(dt);
|
||||
@ -188,8 +188,8 @@ void ReloadableMedia::ReloadTexture()
|
||||
if(LoadedComponent)
|
||||
{
|
||||
LoadedComponent->AllocateGraphicsMemory();
|
||||
GetBaseViewInfo()->SetImageWidth(LoadedComponent->GetBaseViewInfo()->GetImageWidth());
|
||||
GetBaseViewInfo()->SetImageHeight(LoadedComponent->GetBaseViewInfo()->GetImageHeight());
|
||||
BaseViewInfo.SetImageWidth(LoadedComponent->BaseViewInfo.GetImageWidth());
|
||||
BaseViewInfo.SetImageHeight(LoadedComponent->BaseViewInfo.GetImageHeight());
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
@ -251,8 +251,8 @@ void ReloadableMedia::ReloadTexture()
|
||||
if (LoadedComponent != NULL)
|
||||
{
|
||||
LoadedComponent->AllocateGraphicsMemory();
|
||||
GetBaseViewInfo()->SetImageWidth(LoadedComponent->GetBaseViewInfo()->GetImageWidth());
|
||||
GetBaseViewInfo()->SetImageHeight(LoadedComponent->GetBaseViewInfo()->GetImageHeight());
|
||||
BaseViewInfo.SetImageWidth(LoadedComponent->BaseViewInfo.GetImageWidth());
|
||||
BaseViewInfo.SetImageHeight(LoadedComponent->BaseViewInfo.GetImageHeight());
|
||||
}
|
||||
|
||||
}
|
||||
@ -260,8 +260,8 @@ void ReloadableMedia::ReloadTexture()
|
||||
if(!LoadedComponent && TextFallback)
|
||||
{
|
||||
LoadedComponent = new Text(imageBasename, FontInst, ScaleX, ScaleY);
|
||||
GetBaseViewInfo()->SetImageWidth(LoadedComponent->GetBaseViewInfo()->GetImageWidth());
|
||||
GetBaseViewInfo()->SetImageHeight(LoadedComponent->GetBaseViewInfo()->GetImageHeight());
|
||||
BaseViewInfo.SetImageWidth(LoadedComponent->BaseViewInfo.GetImageWidth());
|
||||
BaseViewInfo.SetImageHeight(LoadedComponent->BaseViewInfo.GetImageHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,15 +269,13 @@ void ReloadableMedia::ReloadTexture()
|
||||
|
||||
void ReloadableMedia::Draw()
|
||||
{
|
||||
ViewInfo *info = GetBaseViewInfo();
|
||||
|
||||
Component::Draw();
|
||||
|
||||
if(LoadedComponent)
|
||||
{
|
||||
info->SetImageHeight(LoadedComponent->GetBaseViewInfo()->GetImageHeight());
|
||||
info->SetImageWidth(LoadedComponent->GetBaseViewInfo()->GetImageWidth());
|
||||
LoadedComponent->UpdateBaseViewInfo(*info);
|
||||
BaseViewInfo.SetImageHeight(LoadedComponent->BaseViewInfo.GetImageHeight());
|
||||
BaseViewInfo.SetImageWidth(LoadedComponent->BaseViewInfo.GetImageWidth());
|
||||
LoadedComponent->BaseViewInfo = BaseViewInfo;
|
||||
LoadedComponent->Draw();
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,11 +165,9 @@ void ReloadableText::ReloadTexture()
|
||||
|
||||
void ReloadableText::Draw()
|
||||
{
|
||||
ViewInfo *info = GetBaseViewInfo();
|
||||
|
||||
if(ImageInst)
|
||||
{
|
||||
ImageInst->UpdateBaseViewInfo(*info);
|
||||
ImageInst->BaseViewInfo = BaseViewInfo;
|
||||
ImageInst->Draw();
|
||||
}
|
||||
}
|
||||
|
||||
@ -742,18 +742,18 @@ void ScrollingList::ResetTweens(Component *c, AnimationEvents *sets, ViewInfo *c
|
||||
return;
|
||||
}
|
||||
|
||||
currentViewInfo->SetImageHeight(c->GetBaseViewInfo()->GetImageHeight());
|
||||
currentViewInfo->SetImageWidth(c->GetBaseViewInfo()->GetImageWidth());
|
||||
nextViewInfo->SetImageHeight(c->GetBaseViewInfo()->GetImageHeight());
|
||||
nextViewInfo->SetImageWidth(c->GetBaseViewInfo()->GetImageWidth());
|
||||
nextViewInfo->SetBackgroundAlpha(c->GetBaseViewInfo()->GetBackgroundAlpha());
|
||||
currentViewInfo->SetImageHeight(c->BaseViewInfo.GetImageHeight());
|
||||
currentViewInfo->SetImageWidth(c->BaseViewInfo.GetImageWidth());
|
||||
nextViewInfo->SetImageHeight(c->BaseViewInfo.GetImageHeight());
|
||||
nextViewInfo->SetImageWidth(c->BaseViewInfo.GetImageWidth());
|
||||
nextViewInfo->SetBackgroundAlpha(c->BaseViewInfo.GetBackgroundAlpha());
|
||||
|
||||
//todo: delete properly, memory leak (big), proof of concept
|
||||
c->SetTweens(sets);
|
||||
|
||||
Animation *scrollTween = sets->GetAnimation("menuScroll");
|
||||
scrollTween->Clear();
|
||||
c->UpdateBaseViewInfo(*currentViewInfo);
|
||||
c->BaseViewInfo = *currentViewInfo;
|
||||
|
||||
TweenSet *set = new TweenSet();
|
||||
set->Push(new Tween(TWEEN_PROPERTY_HEIGHT, EASE_INOUT_QUADRATIC, currentViewInfo->GetHeight(), nextViewInfo->GetHeight(), scrollTime));
|
||||
|
||||
@ -56,7 +56,6 @@ void Text::Draw()
|
||||
|
||||
SDL_Texture *t = FontInst->GetTexture();
|
||||
|
||||
ViewInfo *info = GetBaseViewInfo();
|
||||
float imageHeight = 0;
|
||||
float imageWidth = 0;
|
||||
|
||||
@ -77,25 +76,25 @@ void Text::Draw()
|
||||
}
|
||||
|
||||
imageHeight = (float)FontInst->GetHeight();
|
||||
float scale = (float)info->GetFontSize() / (float)imageHeight;
|
||||
float scale = (float)BaseViewInfo.GetFontSize() / (float)imageHeight;
|
||||
|
||||
float oldWidth = info->GetRawWidth();
|
||||
float oldHeight = info->GetRawHeight();
|
||||
float oldImageWidth = info->GetImageHeight();
|
||||
float oldImageHeight = info->GetImageWidth();
|
||||
float oldWidth = BaseViewInfo.GetRawWidth();
|
||||
float oldHeight = BaseViewInfo.GetRawHeight();
|
||||
float oldImageWidth = BaseViewInfo.GetImageHeight();
|
||||
float oldImageHeight = BaseViewInfo.GetImageWidth();
|
||||
|
||||
info->SetWidth(imageWidth*scale);
|
||||
info->SetHeight(info->GetFontSize());
|
||||
info->SetImageWidth(imageWidth);
|
||||
info->SetImageHeight(imageHeight);
|
||||
BaseViewInfo.SetWidth(imageWidth*scale);
|
||||
BaseViewInfo.SetHeight(BaseViewInfo.GetFontSize());
|
||||
BaseViewInfo.SetImageWidth(imageWidth);
|
||||
BaseViewInfo.SetImageHeight(imageHeight);
|
||||
|
||||
float xOrigin = info->GetXRelativeToOrigin();
|
||||
float yOrigin = info->GetYRelativeToOrigin();
|
||||
float xOrigin = BaseViewInfo.GetXRelativeToOrigin();
|
||||
float yOrigin = BaseViewInfo.GetYRelativeToOrigin();
|
||||
|
||||
info->SetWidth(oldWidth);
|
||||
info->SetHeight(oldHeight);
|
||||
info->SetImageWidth(oldImageWidth);
|
||||
info->SetImageHeight(oldImageHeight);
|
||||
BaseViewInfo.SetWidth(oldWidth);
|
||||
BaseViewInfo.SetHeight(oldHeight);
|
||||
BaseViewInfo.SetImageWidth(oldImageWidth);
|
||||
BaseViewInfo.SetImageHeight(oldImageHeight);
|
||||
|
||||
|
||||
SDL_Rect rect;
|
||||
@ -124,11 +123,11 @@ void Text::Draw()
|
||||
}
|
||||
|
||||
|
||||
SDL::RenderCopy(t, static_cast<char>(info->GetAlpha() * 255), &charRect, &rect, info->GetAngle());
|
||||
SDL::RenderCopy(t, static_cast<char>(BaseViewInfo.GetAlpha() * 255), &charRect, &rect, BaseViewInfo.GetAngle());
|
||||
|
||||
rect.x += static_cast<int>(glyph.Advance * scale);
|
||||
|
||||
if((static_cast<float>(rect.x) - xOrigin) > info->GetMaxWidth())
|
||||
if((static_cast<float>(rect.x) - xOrigin) > BaseViewInfo.GetMaxWidth())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@ -47,10 +47,10 @@ void VideoComponent::Update(float dt)
|
||||
VideoInst->Update(dt);
|
||||
|
||||
// video needs to run a frame to start getting size info
|
||||
if(GetBaseViewInfo()->GetImageHeight() == 0 && GetBaseViewInfo()->GetImageWidth() == 0)
|
||||
if(BaseViewInfo.GetImageHeight() == 0 && BaseViewInfo.GetImageWidth() == 0)
|
||||
{
|
||||
GetBaseViewInfo()->SetImageHeight(static_cast<float>(VideoInst->GetHeight()));
|
||||
GetBaseViewInfo()->SetImageWidth(static_cast<float>(VideoInst->GetWidth()));
|
||||
BaseViewInfo.SetImageHeight(static_cast<float>(VideoInst->GetHeight()));
|
||||
BaseViewInfo.SetImageWidth(static_cast<float>(VideoInst->GetWidth()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,19 +87,18 @@ void VideoComponent::LaunchExit()
|
||||
|
||||
void VideoComponent::Draw()
|
||||
{
|
||||
ViewInfo *info = GetBaseViewInfo();
|
||||
SDL_Rect rect;
|
||||
|
||||
rect.x = static_cast<int>(info->GetXRelativeToOrigin());
|
||||
rect.y = static_cast<int>(info->GetYRelativeToOrigin());
|
||||
rect.h = static_cast<int>(info->GetHeight());
|
||||
rect.w = static_cast<int>(info->GetWidth());
|
||||
rect.x = static_cast<int>(BaseViewInfo.GetXRelativeToOrigin());
|
||||
rect.y = static_cast<int>(BaseViewInfo.GetYRelativeToOrigin());
|
||||
rect.h = static_cast<int>(BaseViewInfo.GetHeight());
|
||||
rect.w = static_cast<int>(BaseViewInfo.GetWidth());
|
||||
|
||||
VideoInst->Draw();
|
||||
SDL_Texture *texture = VideoInst->GetTexture();
|
||||
|
||||
if(texture)
|
||||
{
|
||||
SDL::RenderCopy(texture, static_cast<int>(info->GetAlpha() * 255), NULL, &rect, static_cast<int>(info->GetAngle()));
|
||||
SDL::RenderCopy(texture, static_cast<int>(BaseViewInfo.GetAlpha() * 255), NULL, &rect, static_cast<int>(BaseViewInfo.GetAngle()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ bool Page::AddComponent(Component *c)
|
||||
{
|
||||
bool retVal = false;
|
||||
|
||||
unsigned int layer = c->GetBaseViewInfo()->GetLayer();
|
||||
unsigned int layer = c->BaseViewInfo.GetLayer();
|
||||
|
||||
|
||||
if(layer < NUM_LAYERS)
|
||||
|
||||
@ -327,8 +327,7 @@ bool PageBuilder::BuildComponents(xml_node<> *layout, Page *page)
|
||||
for(xml_node<> *componentXml = layout->first_node("container"); componentXml; componentXml = componentXml->next_sibling("container"))
|
||||
{
|
||||
Container *c = new Container();
|
||||
ViewInfo *v = c->GetBaseViewInfo();
|
||||
BuildViewInfo(componentXml, v);
|
||||
BuildViewInfo(componentXml, c->BaseViewInfo);
|
||||
LoadTweens(c, componentXml);
|
||||
page->AddComponent(c);
|
||||
}
|
||||
@ -348,8 +347,7 @@ bool PageBuilder::BuildComponents(xml_node<> *layout, Page *page)
|
||||
imagePath = Utils::CombinePath(Configuration::ConvertToAbsolutePath(LayoutPath, imagePath), std::string(src->value()));
|
||||
|
||||
Image *c = new Image(imagePath, ScaleX, ScaleY);
|
||||
ViewInfo *v = c->GetBaseViewInfo();
|
||||
BuildViewInfo(componentXml, v);
|
||||
BuildViewInfo(componentXml, c->BaseViewInfo);
|
||||
LoadTweens(c, componentXml);
|
||||
page->AddComponent(c);
|
||||
}
|
||||
@ -368,9 +366,8 @@ bool PageBuilder::BuildComponents(xml_node<> *layout, Page *page)
|
||||
{
|
||||
Font *font = AddFont(componentXml, NULL);
|
||||
Text *c = new Text(value->value(), font, ScaleX, ScaleY);
|
||||
ViewInfo *v = c->GetBaseViewInfo();
|
||||
|
||||
BuildViewInfo(componentXml, v);
|
||||
BuildViewInfo(componentXml, c->BaseViewInfo);
|
||||
|
||||
LoadTweens(c, componentXml);
|
||||
page->AddComponent(c);
|
||||
@ -381,9 +378,8 @@ bool PageBuilder::BuildComponents(xml_node<> *layout, Page *page)
|
||||
{
|
||||
Font *font = AddFont(componentXml, NULL);
|
||||
Text *c = new Text("", font, ScaleX, ScaleY);
|
||||
ViewInfo *v = c->GetBaseViewInfo();
|
||||
|
||||
BuildViewInfo(componentXml, v);
|
||||
BuildViewInfo(componentXml, c->BaseViewInfo);
|
||||
|
||||
LoadTweens(c, componentXml);
|
||||
page->AddComponent(c);
|
||||
@ -534,9 +530,7 @@ Font *PageBuilder::AddFont(xml_node<> *component, xml_node<> *defaults)
|
||||
|
||||
void PageBuilder::LoadTweens(Component *c, xml_node<> *componentXml)
|
||||
{
|
||||
ViewInfo *v = c->GetBaseViewInfo();
|
||||
|
||||
BuildViewInfo(componentXml, v);
|
||||
BuildViewInfo(componentXml, c->BaseViewInfo);
|
||||
|
||||
c->SetTweens(CreateTweenInstance(componentXml));
|
||||
}
|
||||
@ -623,8 +617,7 @@ ScrollingList * PageBuilder::BuildMenu(xml_node<> *menuXml)
|
||||
}
|
||||
}
|
||||
|
||||
ViewInfo *v = menu->GetBaseViewInfo();
|
||||
BuildViewInfo(menuXml, v);
|
||||
BuildViewInfo(menuXml, menu->BaseViewInfo);
|
||||
|
||||
if(menuType == "custom")
|
||||
{
|
||||
@ -651,7 +644,7 @@ void PageBuilder::BuildCustomMenu(ScrollingList *menu, xml_node<> *menuXml, xml_
|
||||
for(xml_node<> *componentXml = menuXml->first_node("item"); componentXml; componentXml = componentXml->next_sibling("item"))
|
||||
{
|
||||
ViewInfo *viewInfo = new ViewInfo();
|
||||
BuildViewInfo(componentXml, viewInfo, itemDefaults);
|
||||
BuildViewInfo(componentXml, *viewInfo, itemDefaults);
|
||||
|
||||
points->push_back(viewInfo);
|
||||
tweenPoints->push_back(CreateTweenInstance(componentXml));
|
||||
@ -708,7 +701,7 @@ void PageBuilder::BuildVerticalMenu(ScrollingList *menu, xml_node<> *menuXml, xm
|
||||
if(overrideItems.find(MENU_START) != overrideItems.end())
|
||||
{
|
||||
xml_node<> *component = overrideItems[MENU_START];
|
||||
ViewInfo *viewInfo = CreateMenuItemInfo(component, itemDefaults, menu->GetBaseViewInfo()->GetY() + height);
|
||||
ViewInfo *viewInfo = CreateMenuItemInfo(component, itemDefaults, menu->BaseViewInfo.GetY() + height);
|
||||
points->push_back(viewInfo);
|
||||
tweenPoints->push_back(CreateTweenInstance(component));
|
||||
height += viewInfo->GetHeight();
|
||||
@ -728,12 +721,12 @@ void PageBuilder::BuildVerticalMenu(ScrollingList *menu, xml_node<> *menuXml, xm
|
||||
}
|
||||
|
||||
// calculate the total height of our menu items if we can load any additional items
|
||||
BuildViewInfo(component, viewInfo, itemDefaults);
|
||||
BuildViewInfo(component, *viewInfo, itemDefaults);
|
||||
xml_attribute<> *itemSpacingXml = component->first_attribute("spacing");
|
||||
int itemSpacing = itemSpacingXml ? Utils::ConvertInt(itemSpacingXml->value()) : 0;
|
||||
float nextHeight = height + viewInfo->GetHeight() + itemSpacing;
|
||||
|
||||
if(nextHeight >= menu->GetBaseViewInfo()->GetHeight())
|
||||
if(nextHeight >= menu->BaseViewInfo.GetHeight())
|
||||
{
|
||||
end = true;
|
||||
}
|
||||
@ -743,13 +736,13 @@ void PageBuilder::BuildVerticalMenu(ScrollingList *menu, xml_node<> *menuXml, xm
|
||||
{
|
||||
component = overrideItems[MENU_LAST];
|
||||
|
||||
BuildViewInfo(component, viewInfo, itemDefaults);
|
||||
BuildViewInfo(component, *viewInfo, itemDefaults);
|
||||
xml_attribute<> *itemSpacingXml = component->first_attribute("spacing");
|
||||
int itemSpacing = itemSpacingXml ? Utils::ConvertInt(itemSpacingXml->value()) : 0;
|
||||
nextHeight = height + viewInfo->GetHeight() + itemSpacing;
|
||||
}
|
||||
|
||||
viewInfo->SetY(menu->GetBaseViewInfo()->GetY() + (float)height);
|
||||
viewInfo->SetY(menu->BaseViewInfo.GetY() + (float)height);
|
||||
points->push_back(viewInfo);
|
||||
tweenPoints->push_back(CreateTweenInstance(component));
|
||||
index++;
|
||||
@ -760,7 +753,7 @@ void PageBuilder::BuildVerticalMenu(ScrollingList *menu, xml_node<> *menuXml, xm
|
||||
if(overrideItems.find(MENU_END) != overrideItems.end())
|
||||
{
|
||||
xml_node<> *component = overrideItems[MENU_END];
|
||||
ViewInfo *viewInfo = CreateMenuItemInfo(component, itemDefaults, menu->GetBaseViewInfo()->GetY() + height);
|
||||
ViewInfo *viewInfo = CreateMenuItemInfo(component, itemDefaults, menu->BaseViewInfo.GetY() + height);
|
||||
points->push_back(viewInfo);
|
||||
tweenPoints->push_back(CreateTweenInstance(component));
|
||||
}
|
||||
@ -787,7 +780,7 @@ void PageBuilder::BuildVerticalMenu(ScrollingList *menu, xml_node<> *menuXml, xm
|
||||
ViewInfo *PageBuilder::CreateMenuItemInfo(xml_node<> *component, xml_node<> *defaults, float y)
|
||||
{
|
||||
ViewInfo *viewInfo = new ViewInfo();
|
||||
BuildViewInfo(component, viewInfo, defaults);
|
||||
BuildViewInfo(component, *viewInfo, defaults);
|
||||
viewInfo->SetY(y);
|
||||
return viewInfo;
|
||||
}
|
||||
@ -831,7 +824,7 @@ xml_attribute<> *PageBuilder::FindAttribute(xml_node<> *componentXml, std::strin
|
||||
return attributeXml;
|
||||
}
|
||||
|
||||
void PageBuilder::BuildViewInfo(xml_node<> *componentXml, ViewInfo *info, xml_node<> *defaultXml)
|
||||
void PageBuilder::BuildViewInfo(xml_node<> *componentXml, ViewInfo &info, xml_node<> *defaultXml)
|
||||
{
|
||||
xml_attribute<> *x = FindAttribute(componentXml, "x", defaultXml);
|
||||
xml_attribute<> *y = FindAttribute(componentXml, "y", defaultXml);
|
||||
@ -852,37 +845,37 @@ void PageBuilder::BuildViewInfo(xml_node<> *componentXml, ViewInfo *info, xml_no
|
||||
xml_attribute<> *backgroundColor = FindAttribute(componentXml, "backgroundColor", defaultXml);
|
||||
xml_attribute<> *backgroundAlpha = FindAttribute(componentXml, "backgroundAlpha", defaultXml);
|
||||
|
||||
info->SetX(GetHorizontalAlignment(x, 0));
|
||||
info->SetY(GetVerticalAlignment(y, 0));
|
||||
info.SetX(GetHorizontalAlignment(x, 0));
|
||||
info.SetY(GetVerticalAlignment(y, 0));
|
||||
|
||||
info->SetXOffset( GetHorizontalAlignment(xOffset, 0));
|
||||
info->SetYOffset( GetVerticalAlignment(yOffset, 0));
|
||||
info.SetXOffset( GetHorizontalAlignment(xOffset, 0));
|
||||
info.SetYOffset( GetVerticalAlignment(yOffset, 0));
|
||||
float xOriginRelative = GetHorizontalAlignment(xOrigin, 0);
|
||||
float yOriginRelative = GetVerticalAlignment(yOrigin, 0);
|
||||
|
||||
// the origins need to be saved as a percent since the heights and widths can be scaled
|
||||
info->SetXOrigin(xOriginRelative / ScreenWidth);
|
||||
info->SetYOrigin(yOriginRelative / ScreenHeight);
|
||||
info.SetXOrigin(xOriginRelative / ScreenWidth);
|
||||
info.SetYOrigin(yOriginRelative / ScreenHeight);
|
||||
|
||||
|
||||
if(!height && !width)
|
||||
{
|
||||
info->SetHeight(-1);
|
||||
info->SetWidth(-1);
|
||||
info.SetHeight(-1);
|
||||
info.SetWidth(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
info->SetHeight(GetVerticalAlignment(height, -1));
|
||||
info->SetWidth(GetHorizontalAlignment(width, -1));
|
||||
info.SetHeight(GetVerticalAlignment(height, -1));
|
||||
info.SetWidth(GetHorizontalAlignment(width, -1));
|
||||
}
|
||||
info->SetFontSize(GetVerticalAlignment(fontSize, -1));
|
||||
info->SetMinHeight(GetVerticalAlignment(minHeight, 0));
|
||||
info->SetMinWidth(GetHorizontalAlignment(minWidth, 0));
|
||||
info->SetMaxHeight(GetVerticalAlignment(maxHeight, FLT_MAX));
|
||||
info->SetMaxWidth(GetVerticalAlignment(maxWidth, FLT_MAX));
|
||||
info->SetAlpha( alpha ? Utils::ConvertFloat(alpha->value()) : 1);
|
||||
info->SetAngle( angle ? Utils::ConvertFloat(angle->value()) : 0);
|
||||
info->SetLayer( layer ? Utils::ConvertInt(layer->value()) : 0);
|
||||
info.SetFontSize(GetVerticalAlignment(fontSize, -1));
|
||||
info.SetMinHeight(GetVerticalAlignment(minHeight, 0));
|
||||
info.SetMinWidth(GetHorizontalAlignment(minWidth, 0));
|
||||
info.SetMaxHeight(GetVerticalAlignment(maxHeight, FLT_MAX));
|
||||
info.SetMaxWidth(GetVerticalAlignment(maxWidth, FLT_MAX));
|
||||
info.SetAlpha( alpha ? Utils::ConvertFloat(alpha->value()) : 1);
|
||||
info.SetAngle( angle ? Utils::ConvertFloat(angle->value()) : 0);
|
||||
info.SetLayer( layer ? Utils::ConvertInt(layer->value()) : 0);
|
||||
|
||||
if(backgroundColor)
|
||||
{
|
||||
@ -893,14 +886,14 @@ void PageBuilder::BuildViewInfo(xml_node<> *componentXml, ViewInfo *info, xml_no
|
||||
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);
|
||||
info.SetBackgroundRed(static_cast<float>(red)/255);
|
||||
info.SetBackgroundGreen(static_cast<float>(green)/255);
|
||||
info.SetBackgroundBlue(static_cast<float>(blue)/255);
|
||||
}
|
||||
|
||||
if(backgroundAlpha)
|
||||
{
|
||||
info->SetBackgroundAlpha( backgroundAlpha ? Utils::ConvertFloat(backgroundAlpha->value()) : 1);
|
||||
info.SetBackgroundAlpha( backgroundAlpha ? Utils::ConvertFloat(backgroundAlpha->value()) : 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ private:
|
||||
void LoadReloadableImages(rapidxml::xml_node<> *layout, std::string tagName, Page *page);
|
||||
float GetVerticalAlignment(rapidxml::xml_attribute<> *attribute, float valueIfNull);
|
||||
float GetHorizontalAlignment(rapidxml::xml_attribute<> *attribute, float valueIfNull);
|
||||
void BuildViewInfo(rapidxml::xml_node<> *componentXml, ViewInfo *info, rapidxml::xml_node<> *defaultXml = NULL);
|
||||
void BuildViewInfo(rapidxml::xml_node<> *componentXml, ViewInfo &info, rapidxml::xml_node<> *defaultXml = NULL);
|
||||
bool BuildComponents(rapidxml::xml_node<> *layout, Page *page);
|
||||
void LoadTweens(Component *c, rapidxml::xml_node<> *componentXml);
|
||||
AnimationEvents *CreateTweenInstance(rapidxml::xml_node<> *componentXml);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user