From 8f6658dd13db29ba893aa1fdf494e6124a6174af Mon Sep 17 00:00:00 2001 From: Don Honerbrink Date: Tue, 23 Jun 2015 14:12:20 -0500 Subject: [PATCH] Making BaseViewInfo public. --- .../Source/Graphics/Component/Component.cpp | 49 +++++------ RetroFE/Source/Graphics/Component/Component.h | 4 +- RetroFE/Source/Graphics/Component/Image.cpp | 15 ++-- .../Graphics/Component/ReloadableMedia.cpp | 26 +++--- .../Graphics/Component/ReloadableText.cpp | 4 +- .../Graphics/Component/ScrollingList.cpp | 12 +-- RetroFE/Source/Graphics/Component/Text.cpp | 35 ++++---- .../Graphics/Component/VideoComponent.cpp | 17 ++-- RetroFE/Source/Graphics/Page.cpp | 2 +- RetroFE/Source/Graphics/PageBuilder.cpp | 81 +++++++++---------- RetroFE/Source/Graphics/PageBuilder.h | 2 +- 11 files changed, 111 insertions(+), 136 deletions(-) diff --git a/RetroFE/Source/Graphics/Component/Component.cpp b/RetroFE/Source/Graphics/Component/Component.cpp index aa9936c..fd20fae 100644 --- a/RetroFE/Source/Graphics/Component/Component.cpp +++ b/RetroFE/Source/Graphics/Component/Component.cpp @@ -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(info->GetHeight()); - rect.w = static_cast(info->GetWidth()); - rect.x = static_cast(info->GetXRelativeToOrigin()); - rect.y = static_cast(info->GetYRelativeToOrigin()); + rect.h = static_cast(BaseViewInfo.GetHeight()); + rect.w = static_cast(BaseViewInfo.GetWidth()); + rect.x = static_cast(BaseViewInfo.GetXRelativeToOrigin()); + rect.y = static_cast(BaseViewInfo.GetYRelativeToOrigin()); SDL_SetTextureColorMod(BackgroundTexture, - static_cast(info->GetBackgroundRed()*255), - static_cast(info->GetBackgroundGreen()*255), - static_cast(info->GetBackgroundBlue()*255)); + static_cast(BaseViewInfo.GetBackgroundRed()*255), + static_cast(BaseViewInfo.GetBackgroundGreen()*255), + static_cast(BaseViewInfo.GetBackgroundBlue()*255)); - SDL::RenderCopy(BackgroundTexture, static_cast(info->GetBackgroundAlpha()*255), NULL, &rect, info->GetAngle()); + SDL::RenderCopy(BackgroundTexture, static_cast(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; } } diff --git a/RetroFE/Source/Graphics/Component/Component.h b/RetroFE/Source/Graphics/Component/Component.h index 192ec63..7416844 100644 --- a/RetroFE/Source/Graphics/Component/Component.h +++ b/RetroFE/Source/Graphics/Component/Component.h @@ -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; }; diff --git a/RetroFE/Source/Graphics/Component/Image.cpp b/RetroFE/Source/Graphics/Component/Image.cpp index 9fb268e..8d9ea45 100644 --- a/RetroFE/Source/Graphics/Component/Image.cpp +++ b/RetroFE/Source/Graphics/Component/Image.cpp @@ -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(info->GetXRelativeToOrigin()); - rect.y = static_cast(info->GetYRelativeToOrigin()); - rect.h = static_cast(info->GetHeight()); - rect.w = static_cast(info->GetWidth()); + rect.x = static_cast(BaseViewInfo.GetXRelativeToOrigin()); + rect.y = static_cast(BaseViewInfo.GetYRelativeToOrigin()); + rect.h = static_cast(BaseViewInfo.GetHeight()); + rect.w = static_cast(BaseViewInfo.GetWidth()); - SDL::RenderCopy(Texture, static_cast((info->GetAlpha() * 255)), NULL, &rect, info->GetAngle()); + SDL::RenderCopy(Texture, static_cast((BaseViewInfo.GetAlpha() * 255)), NULL, &rect, BaseViewInfo.GetAngle()); } } diff --git a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp index 96e9e3b..6b62e25 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableMedia.cpp @@ -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(); } } diff --git a/RetroFE/Source/Graphics/Component/ReloadableText.cpp b/RetroFE/Source/Graphics/Component/ReloadableText.cpp index 87c4b60..d0a742e 100644 --- a/RetroFE/Source/Graphics/Component/ReloadableText.cpp +++ b/RetroFE/Source/Graphics/Component/ReloadableText.cpp @@ -165,11 +165,9 @@ void ReloadableText::ReloadTexture() void ReloadableText::Draw() { - ViewInfo *info = GetBaseViewInfo(); - if(ImageInst) { - ImageInst->UpdateBaseViewInfo(*info); + ImageInst->BaseViewInfo = BaseViewInfo; ImageInst->Draw(); } } diff --git a/RetroFE/Source/Graphics/Component/ScrollingList.cpp b/RetroFE/Source/Graphics/Component/ScrollingList.cpp index 6e7b3bd..36d3a6c 100644 --- a/RetroFE/Source/Graphics/Component/ScrollingList.cpp +++ b/RetroFE/Source/Graphics/Component/ScrollingList.cpp @@ -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)); diff --git a/RetroFE/Source/Graphics/Component/Text.cpp b/RetroFE/Source/Graphics/Component/Text.cpp index 4012621..1400294 100644 --- a/RetroFE/Source/Graphics/Component/Text.cpp +++ b/RetroFE/Source/Graphics/Component/Text.cpp @@ -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(info->GetAlpha() * 255), &charRect, &rect, info->GetAngle()); + SDL::RenderCopy(t, static_cast(BaseViewInfo.GetAlpha() * 255), &charRect, &rect, BaseViewInfo.GetAngle()); rect.x += static_cast(glyph.Advance * scale); - if((static_cast(rect.x) - xOrigin) > info->GetMaxWidth()) + if((static_cast(rect.x) - xOrigin) > BaseViewInfo.GetMaxWidth()) { break; } diff --git a/RetroFE/Source/Graphics/Component/VideoComponent.cpp b/RetroFE/Source/Graphics/Component/VideoComponent.cpp index 9278b2d..ac90dc2 100644 --- a/RetroFE/Source/Graphics/Component/VideoComponent.cpp +++ b/RetroFE/Source/Graphics/Component/VideoComponent.cpp @@ -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(VideoInst->GetHeight())); - GetBaseViewInfo()->SetImageWidth(static_cast(VideoInst->GetWidth())); + BaseViewInfo.SetImageHeight(static_cast(VideoInst->GetHeight())); + BaseViewInfo.SetImageWidth(static_cast(VideoInst->GetWidth())); } } @@ -87,19 +87,18 @@ void VideoComponent::LaunchExit() void VideoComponent::Draw() { - ViewInfo *info = GetBaseViewInfo(); SDL_Rect rect; - rect.x = static_cast(info->GetXRelativeToOrigin()); - rect.y = static_cast(info->GetYRelativeToOrigin()); - rect.h = static_cast(info->GetHeight()); - rect.w = static_cast(info->GetWidth()); + rect.x = static_cast(BaseViewInfo.GetXRelativeToOrigin()); + rect.y = static_cast(BaseViewInfo.GetYRelativeToOrigin()); + rect.h = static_cast(BaseViewInfo.GetHeight()); + rect.w = static_cast(BaseViewInfo.GetWidth()); VideoInst->Draw(); SDL_Texture *texture = VideoInst->GetTexture(); if(texture) { - SDL::RenderCopy(texture, static_cast(info->GetAlpha() * 255), NULL, &rect, static_cast(info->GetAngle())); + SDL::RenderCopy(texture, static_cast(BaseViewInfo.GetAlpha() * 255), NULL, &rect, static_cast(BaseViewInfo.GetAngle())); } } diff --git a/RetroFE/Source/Graphics/Page.cpp b/RetroFE/Source/Graphics/Page.cpp index d016238..7878546 100644 --- a/RetroFE/Source/Graphics/Page.cpp +++ b/RetroFE/Source/Graphics/Page.cpp @@ -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) diff --git a/RetroFE/Source/Graphics/PageBuilder.cpp b/RetroFE/Source/Graphics/PageBuilder.cpp index a2bee57..1582e5c 100644 --- a/RetroFE/Source/Graphics/PageBuilder.cpp +++ b/RetroFE/Source/Graphics/PageBuilder.cpp @@ -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(red)/255); - info->SetBackgroundGreen(static_cast(green)/255); - info->SetBackgroundBlue(static_cast(blue)/255); + info.SetBackgroundRed(static_cast(red)/255); + info.SetBackgroundGreen(static_cast(green)/255); + info.SetBackgroundBlue(static_cast(blue)/255); } if(backgroundAlpha) { - info->SetBackgroundAlpha( backgroundAlpha ? Utils::ConvertFloat(backgroundAlpha->value()) : 1); + info.SetBackgroundAlpha( backgroundAlpha ? Utils::ConvertFloat(backgroundAlpha->value()) : 1); } } diff --git a/RetroFE/Source/Graphics/PageBuilder.h b/RetroFE/Source/Graphics/PageBuilder.h index 95020b3..2a01183 100644 --- a/RetroFE/Source/Graphics/PageBuilder.h +++ b/RetroFE/Source/Graphics/PageBuilder.h @@ -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);