// Runs the physics simulation. // - TDeltaTime tells the simulation how much time has passed since the last frame so the simulation can run independently of the frame rate. void Application::UpdatePhysics(u32 TDeltaTime) { World->stepSimulation(TDeltaTime * 0.001f, 60); // Relay the object's orientation to irrlicht for(list<btRigidBody *>::Iterator Iterator = Objects.begin(); Iterator != Objects.end(); ++Iterator) { UpdateRender(*Iterator); } }
/// <summary> /// Start the render timer. /// If a renderer has not been created yet, it will be created from the options. /// </summary> void FractoriumEmberControllerBase::StartRenderTimer() { if (m_RenderTimer) { UpdateRender(); m_RenderTimer->start(); m_RenderElapsedTimer.Tic(); } }
// Constructor _Camera::_Camera() { Type = THIRD_PERSON; LookAt = glm::vec3(0, 0, 0); Position = LastPosition = glm::vec3(0, 0, 5); Yaw = 0.0f; Pitch = 0.0f; Distance = 5.0f; PitchLimit = glm::radians(85.0f); Sensitivity[0] = 0.4f; Sensitivity[1] = 0.4f; UpdateRender(0.0f); }
void UIScreenEldBindInputs::InitializeFromDefinition( const SimpleString& DefinitionName ) { FlushWidgets(); UIScreen::InitializeFromDefinition( DefinitionName ); EldritchFramework* const pFramework = EldritchFramework::GetInstance(); ASSERT( pFramework ); InputSystem* const pInputSystem = pFramework->GetInputSystem(); ASSERT( pInputSystem ); const Array<SimpleString>& ExposedInputs = pInputSystem->GetExposedInputs(); ASSERT( ExposedInputs.Size() ); MAKEHASH( DefinitionName ); CreateRulesDefinition(); const uint NumExposedInputs = ExposedInputs.Size(); for( m_ExposedInputIndex = 0; m_ExposedInputIndex < NumExposedInputs; ++m_ExposedInputIndex ) { m_ExposedInput = ExposedInputs[ m_ExposedInputIndex ]; m_Y = m_YBase + m_ExposedInputIndex * m_YStep; CreateLabelWidgetDefinition(); CreateKeyboardWidgetDefinition(); CreateMouseWidgetDefinition(); CreateControllerWidgetDefinition(); CreateBindingActionDefinition(); CreateCompositeWidgetDefinition(); CreateCompositeWidget(); } UpdateRender(); // Initialize focus to the first element (so that we're never unfocused, // because that doesn't make sense for controllers). if( m_FocusWidgets.Size() > 0 ) { m_FocusedWidget = m_FocusWidgets[0]; // NOTE: Intentionally not calling SetFocus here, so effects don't happen; we // just need an initial focus for controllers, it's not really *getting* focus } }
void UIWidgetText::Refresh() { UIWidget::Refresh(); if( m_DynamicString != "" ) { const SimpleString ResolvedDynamicString = StringManager::ParseConfigString( StringManager::ESL_Transient, m_DynamicString.CStr() ); const bool StringChanged = ( ResolvedDynamicString != m_String ); m_String = ResolvedDynamicString; if( StringChanged ) { if( m_IsDynamicPosition ) { UpdatePosition(); UpdateRenderPosition(); } UpdateRender(); } } }
void UIWidgetText::InitializeFromDefinition( const SimpleString& DefinitionName ) { UIWidget::InitializeFromDefinition( DefinitionName ); MAKEHASH( m_Archetype ); MAKEHASH( DefinitionName ); STATICHASH( Font ); m_Font = m_UIManager->GetRenderer()->GetFontManager()->GetFont( ConfigManager::GetArchetypeString( sFont, sm_Archetype, DEFAULT_FONT, sDefinitionName ) ); // If LoadString is false, we're expecting to dynamically set the string in code somewhere STATICHASH( LoadString ); if( ConfigManager::GetArchetypeBool( sLoadString, sm_Archetype, true, sDefinitionName ) ) { STATICHASH( String ); STATICHASH( DynamicString ); STATICHASH( IsLiteral ); m_IsLiteral = ConfigManager::GetArchetypeBool( sIsLiteral, sm_Archetype, false, sDefinitionName ); if( m_IsLiteral ) { m_String = ConfigManager::GetArchetypeString( sString, sm_Archetype, "", sDefinitionName ); m_DynamicString = ConfigManager::GetArchetypeString( sDynamicString, sm_Archetype, "", sDefinitionName ); } else { m_String = ConfigManager::GetLocalizedString( ConfigManager::GetArchetypeHash( sString, sm_Archetype, "", sDefinitionName ), "" ); m_DynamicString = ConfigManager::GetLocalizedString( ConfigManager::GetArchetypeHash( sDynamicString, sm_Archetype, "", sDefinitionName ), "" ); } } STATICHASH( IsDynamicPosition ); m_IsDynamicPosition = ConfigManager::GetArchetypeBool( sIsDynamicPosition, sm_Archetype, false, sDefinitionName ); STATICHASH( Alignment ); GetFontPrintFlags( ConfigManager::GetArchetypeString( sAlignment, sm_Archetype, "", sDefinitionName ) ); STATICHASH( HasDropShadow ); m_HasDropShadow = ConfigManager::GetArchetypeBool( sHasDropShadow, sm_Archetype, false, sDefinitionName ); STATICHASH( DropShadowColorR ); m_DropShadowColor.r = ConfigManager::GetArchetypeFloat( sDropShadowColorR, sm_Archetype, 1.0f, sDefinitionName ); STATICHASH( DropShadowColorG ); m_DropShadowColor.g = ConfigManager::GetArchetypeFloat( sDropShadowColorG, sm_Archetype, 1.0f, sDefinitionName ); STATICHASH( DropShadowColorB ); m_DropShadowColor.b = ConfigManager::GetArchetypeFloat( sDropShadowColorB, sm_Archetype, 1.0f, sDefinitionName ); STATICHASH( DropShadowColorA ); m_DropShadowColor.a = ConfigManager::GetArchetypeFloat( sDropShadowColorA, sm_Archetype, 1.0f, sDefinitionName ); STATICHASH( DisplayWidth ); const float fDisplayWidth = static_cast<float>( ConfigManager::GetInt( sDisplayWidth ) ); STATICHASH( DisplayHeight ); const float fDisplayHeight = static_cast<float>( ConfigManager::GetInt( sDisplayHeight ) ); STATICHASH( WrapPixelWidth ); STATICHASH( WrapScreenWidth ); m_WrapWidth = Pick( ConfigManager::GetArchetypeFloat( sWrapPixelWidth, sm_Archetype, 0.0f, sDefinitionName ), fDisplayWidth * ConfigManager::GetArchetypeFloat( sWrapScreenWidth, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( DropShadowOffsetPixelX ); STATICHASH( DropShadowOffsetScreenX ); m_DropShadowOffset.x = Pick( ConfigManager::GetArchetypeFloat( sDropShadowOffsetPixelX, sm_Archetype, 0.0f, sDefinitionName ), fDisplayWidth * ConfigManager::GetArchetypeFloat( sDropShadowOffsetScreenX, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( DropShadowOffsetPixelY ); STATICHASH( DropShadowOffsetScreenY ); m_DropShadowOffset.y = Pick( ConfigManager::GetArchetypeFloat( sDropShadowOffsetPixelY, sm_Archetype, 0.0f, sDefinitionName ), fDisplayHeight * ConfigManager::GetArchetypeFloat( sDropShadowOffsetScreenY, sm_Archetype, 0.0f, sDefinitionName ) ); UpdatePosition(); UpdateRender(); }
void UIWidgetImage::InitializeFromDefinition( const SimpleString& DefinitionName ) { UIWidget::InitializeFromDefinition( DefinitionName ); MAKEHASH( DefinitionName ); MAKEHASH( m_Archetype ); STATICHASH( DisplayWidth ); const float DisplayWidth = ConfigManager::GetFloat( sDisplayWidth ); const float ParentWidth = m_OriginParent ? m_OriginParent->GetWidth() : DisplayWidth; const float ParentX = m_OriginParent ? Ceiling( m_OriginParent->GetX() ) : 0.0f; STATICHASH( DisplayHeight ); const float DisplayHeight = ConfigManager::GetFloat( sDisplayHeight ); const float ParentHeight = m_OriginParent ? m_OriginParent->GetHeight() : DisplayHeight; const float ParentY = m_OriginParent ? Ceiling( m_OriginParent->GetY() ) : 0.0f; STATICHASH( PixelX ); STATICHASH( ScreenX ); float X = Pick( ConfigManager::GetArchetypeFloat( sPixelX, sm_Archetype, 0.0f, sDefinitionName ), ParentWidth * ConfigManager::GetArchetypeFloat( sScreenX, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelY ); STATICHASH( ScreenY ); float Y = Pick( ConfigManager::GetArchetypeFloat( sPixelY, sm_Archetype, 0.0f, sDefinitionName ), ParentHeight * ConfigManager::GetArchetypeFloat( sScreenY, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelWidth ); STATICHASH( ScreenWidth ); float Width = Pick( ConfigManager::GetArchetypeFloat( sPixelWidth, sm_Archetype, 0.0f, sDefinitionName ), ParentWidth * ConfigManager::GetArchetypeFloat( sScreenWidth, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelHeight ); STATICHASH( ScreenHeight ); float Height = Pick( ConfigManager::GetArchetypeFloat( sPixelHeight, sm_Archetype, 0.0f, sDefinitionName ), ParentHeight * ConfigManager::GetArchetypeFloat( sScreenHeight, sm_Archetype, 0.0f, sDefinitionName ) ); // Adjust for desired aspect ratio if one dimension is not given // (This is used to size images using ScreenWidth or ScreenHeight // properly regardless of screen aspect ratio. STATICHASH( AspectRatio ); const float AspectRatio = ConfigManager::GetArchetypeFloat( sAspectRatio, sm_Archetype, 1.0f, sDefinitionName ); if( Width == 0.0f ) { Width = Height * AspectRatio; } else if( Height == 0.0f ) { Height = Width / AspectRatio; } // Offset relative to resolved image dimensions if specified STATICHASH( ImageX ); X = Pick( X, ConfigManager::GetArchetypeFloat( sImageX, sm_Archetype, 0.0f, sDefinitionName ) * Width ); STATICHASH( ImageY ); Y = Pick( Y, ConfigManager::GetArchetypeFloat( sImageY, sm_Archetype, 0.0f, sDefinitionName ) * Height ); AdjustDimensionsToParent( X, Y, Width, Height, ParentX, ParentY, ParentWidth, ParentHeight ); GetPositionFromOrigin( X, Y, Width, Height ); STATICHASH( ClampToPixelGrid ); if( ConfigManager::GetArchetypeBool( sClampToPixelGrid, sm_Archetype, true, sDefinitionName ) ) { m_TopLeft.x = Round( m_TopLeft.x ); m_TopLeft.y = Round( m_TopLeft.y ); } // Offset to properly align on pixel grid. const float PixelGridOffset = GetPixelGridOffset(); m_TopLeft.x -= PixelGridOffset; m_TopLeft.y -= PixelGridOffset; // If LoadImage is false, we're expecting to dynamically set the texture in code somewhere STATICHASH( LoadImage ); if( ConfigManager::GetArchetypeBool( sLoadImage, sm_Archetype, true, sDefinitionName ) ) { STATICHASH( Image ); SetTexture( ConfigManager::GetArchetypeString( sImage, sm_Archetype, DEFAULT_TEXTURE, sDefinitionName ) ); } m_Dimensions = Vector2( Width, Height ); STATICHASH( Calibration ); m_Calibration = ConfigManager::GetArchetypeBool( sCalibration, sm_Archetype, false, sDefinitionName ); STATICHASH( MaterialOverride ); const SimpleString DefaultMaterial( "Material_HUD" ); m_Material = ConfigManager::GetArchetypeString( sMaterialOverride, sm_Archetype, DefaultMaterial.CStr(), sDefinitionName ); UpdateRender(); }
// HACK: Supporting Eldritch character screen. // Note that we call UpdateRender here since image widgets don't normally refresh their textures. void UIWidgetImage::SetTexture( ITexture* const pTexture ) { m_Texture = pTexture; UpdateRender(); }
WorldObjectWidget::WorldObjectWidget(QWidget *parent) : QWidget(parent), ui(new Ui::WorldObjectWidget) { ui->setupUi(this); selection.object = 0; selection_type = 0; UnsetSelection(); ui->actionsButton->setMenu(&action_menu); connect(ui->objectName, SIGNAL(textChanged(QString)), this, SLOT(UpdateName(QString))); // Geometry connect(ui->objectPosX, SIGNAL(valueChanged(double)), this, SLOT(UpdateGeometry())); connect(ui->objectPosY, SIGNAL(valueChanged(double)), this, SLOT(UpdateGeometry())); connect(ui->objectPosZ, SIGNAL(valueChanged(double)), this, SLOT(UpdateGeometry())); connect(ui->objectRotationX, SIGNAL(valueChanged(double)), this, SLOT(UpdateGeometry())); connect(ui->objectRotationY, SIGNAL(valueChanged(double)), this, SLOT(UpdateGeometry())); connect(ui->objectRotationZ, SIGNAL(valueChanged(double)), this, SLOT(UpdateGeometry())); connect(ui->objectScaleX, SIGNAL(valueChanged(double)), this, SLOT(UpdateGeometry())); connect(ui->objectScaleY, SIGNAL(valueChanged(double)), this, SLOT(UpdateGeometry())); connect(ui->objectScaleZ, SIGNAL(valueChanged(double)), this, SLOT(UpdateGeometry())); connect(ui->objectFloor, SIGNAL(valueChanged(int)), this, SLOT(UpdateFloor())); connect(ui->inheritsFloor, SIGNAL(toggled(bool)), this, SLOT(UpdateFloor())); // Collider connect(ui->displayColliders, SIGNAL(toggled(bool)), this, SLOT(UpdateColliderDisplay())); connect(ui->collider_type, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateColliderType())); connect(ui->collider_pos_x, SIGNAL(valueChanged(double)), this, SLOT(UpdateColliderGeometry())); connect(ui->collider_pos_y, SIGNAL(valueChanged(double)), this, SLOT(UpdateColliderGeometry())); connect(ui->collider_pos_z, SIGNAL(valueChanged(double)), this, SLOT(UpdateColliderGeometry())); connect(ui->collider_hpr_x, SIGNAL(valueChanged(double)), this, SLOT(UpdateColliderGeometry())); connect(ui->collider_hpr_y, SIGNAL(valueChanged(double)), this, SLOT(UpdateColliderGeometry())); connect(ui->collider_hpr_z, SIGNAL(valueChanged(double)), this, SLOT(UpdateColliderGeometry())); connect(ui->collider_scale_x, SIGNAL(valueChanged(double)), this, SLOT(UpdateColliderGeometry())); connect(ui->collider_scale_y, SIGNAL(valueChanged(double)), this, SLOT(UpdateColliderGeometry())); connect(ui->collider_scale_z, SIGNAL(valueChanged(double)), this, SLOT(UpdateColliderGeometry())); // Light connect(ui->lightSetEnabled, SIGNAL(toggled(bool)), this, SLOT(LightSetEnabled(bool))); connect(ui->lightSetDisabled, SIGNAL(toggled(bool)), this, SLOT(LightSetDisabled(bool))); connect(ui->lightColorR, SIGNAL(valueChanged(double)), this, SLOT(UpdateLightColor())); connect(ui->lightColorG, SIGNAL(valueChanged(double)), this, SLOT(UpdateLightColor())); connect(ui->lightColorB, SIGNAL(valueChanged(double)), this, SLOT(UpdateLightColor())); connect(ui->lightAttenuationA, SIGNAL(valueChanged(double)), this, SLOT(UpdateLightAttenuation())); connect(ui->lightAttenuationB, SIGNAL(valueChanged(double)), this, SLOT(UpdateLightAttenuation())); connect(ui->lightAttenuationC, SIGNAL(valueChanged(double)), this, SLOT(UpdateLightAttenuation())); connect(ui->lightTypesList, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateLightType())); connect(ui->lightCompile, SIGNAL(clicked()), this, SLOT(LightCompile())); connect(ui->lightPriority, SIGNAL(valueChanged(int)), this, SLOT(UpdateLightPriority())); connect(ui->addLightTarget, SIGNAL(clicked()), this, SLOT(AddEnlightenedObject())); connect(ui->deleteLightTarget, SIGNAL(clicked()), this, SLOT(DeleteEnlightenedObject())); connect(ui->showFrustum, SIGNAL(toggled(bool)), this, SLOT(LightShowFrustum(bool))); connect(ui->lightTargets, SIGNAL(updatedPriority()), this, SLOT(UpdateEnlightenedObject())); connect(ui->lightTargets, SIGNAL(updatedPropagation()), this, SLOT(UpdateEnlightenedObject())); // Light -> Shadow caster connect(ui->shadowFilmSize, SIGNAL(valueChanged(int)), this, SLOT(UpdateShadowCaster())); connect(ui->shadowNear, SIGNAL(valueChanged(int)), this, SLOT(UpdateShadowCaster())); connect(ui->shadowFar, SIGNAL(valueChanged(int)), this, SLOT(UpdateShadowCaster())); connect(ui->shadowBufferSizeX, SIGNAL(valueChanged(int)), this, SLOT(UpdateShadowCaster())); connect(ui->shadowBufferSizeY, SIGNAL(valueChanged(int)), this, SLOT(UpdateShadowCaster())); // Render connect(ui->selectModel, SIGNAL(clicked()), this, SLOT(PickModel())); connect(ui->selectTexture, SIGNAL(clicked()), this, SLOT(PickTexture())); connect(ui->objectModel, SIGNAL(textChanged(QString)), this, SLOT(UpdateRender())); connect(ui->objectTexture, SIGNAL(textChanged(QString)), this, SLOT(UpdateRender())); connect(ui->objectFocus, SIGNAL(clicked()), this, SLOT(FocusCurrentObject())); connect(ui->useTexture, SIGNAL(toggled(bool)), this, SLOT(UpdateRender())); connect(ui->useColor, SIGNAL(toggled(bool)), this, SLOT(UpdateRender())); connect(ui->useOpacity, SIGNAL(toggled(bool)), this, SLOT(UpdateRender())); connect(ui->colorRed, SIGNAL(valueChanged(double)), SLOT(UpdateRender())); connect(ui->colorGreen, SIGNAL(valueChanged(double)), SLOT(UpdateRender())); connect(ui->colorBlue, SIGNAL(valueChanged(double)), SLOT(UpdateRender())); connect(ui->opacity, SIGNAL(valueChanged(double)), SLOT(UpdateRender())); connect(ui->objectToggleVisibility, SIGNAL(clicked()), this, SLOT(ToogleCurrentObject())); // Waypoint connect(ui->setCurrentWaypoint, SIGNAL(clicked()), this, SLOT(SetCurrentWaypoint())); connect(ui->selectCurrentWaypoint, SIGNAL(clicked()), this, SLOT(SelectCurrentWaypoint())); // Behaviour connect(ui->objectTypeList, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateBehaviour())); connect(ui->character, SIGNAL(textChanged(QString)), this, SLOT(UpdateBehaviour())); connect(ui->dialog, SIGNAL(textChanged(QString)), this, SLOT(UpdateBehaviour())); connect(ui->script, SIGNAL(textChanged(QString)), this, SLOT(UpdateBehaviour())); connect(ui->doorLocked, SIGNAL(toggled(bool)), this, SLOT(UpdateBehaviour())); connect(ui->key, SIGNAL(textChanged(QString)), this, SLOT(UpdateBehaviour())); connect(ui->interactionUse, SIGNAL(toggled(bool)), this, SLOT(UpdateBehaviour())); connect(ui->interactionUseSkill, SIGNAL(toggled(bool)), this, SLOT(UpdateBehaviour())); connect(ui->interactionUseSpell, SIGNAL(toggled(bool)), this, SLOT(UpdateBehaviour())); connect(ui->interactionUseObject, SIGNAL(toggled(bool)), this, SLOT(UpdateBehaviour())); connect(ui->interactionLookAt, SIGNAL(toggled(bool)), this, SLOT(UpdateBehaviour())); connect(ui->interactionTalkTo, SIGNAL(toggled(bool)), this, SLOT(UpdateBehaviour())); connect(ui->selectCharacter, SIGNAL(clicked()), this, SLOT(SelectCharacter())); connect(ui->selectItem, SIGNAL(clicked()), this, SLOT(SelectItem())); connect(ui->selectKey, SIGNAL(clicked()), this, SLOT(SelectKey())); connect(ui->selectScript, SIGNAL(clicked()), this, SLOT(SelectScript())); connect(ui->selectDialog, SIGNAL(clicked()), this, SLOT(SelectDialog())); // Render Particles connect(ui->particleEffectName, SIGNAL(textChanged(QString)), this, SLOT(UpdateParticleEffect())); connect(ui->showParticleEffect, SIGNAL(clicked()), this, SLOT(RestartParticleEffect())); connect(ui->selectParticleEffect, SIGNAL(clicked()), this, SLOT(SelectParticleEffect())); ui->actionsButton->setMenu(&action_menu); action_menu.addAction("Copy", this, SIGNAL(CopyRequested()), QKeySequence::Copy); action_menu.addAction("Paste", this, SIGNAL(PasteRequested()), QKeySequence::Paste); }
void UIScreenEldSetRes::InitializeFromDefinition( const SimpleString& DefinitionName) { FlushWidgets(); m_ResMap.Clear(); UIScreen::InitializeFromDefinition(DefinitionName); Display* const pDisplay = m_UIManager->GetDisplay(); Array<SDisplayMode> DisplayModes; m_UIManager->GetRenderer()->EnumerateDisplayModes(DisplayModes); DisplayModes.InsertionSort(); ASSERT(DisplayModes.Size()); MAKEHASH(DefinitionName); // Dynamically create definitions for each text button STATICHASH(Rules); SimpleString UsingRules = ConfigManager::GetString(sRules, "", sDefinitionName); MAKEHASH(UsingRules); STATICHASH(Archetype); const char* const ArchetypeName = ConfigManager::GetString(sArchetype, "", sUsingRules); STATICHASH(Parent); const char* const Parent = ConfigManager::GetString(sParent, "", sUsingRules); STATICHASH(PixelYBase); const float YBase = ConfigManager::GetFloat(sPixelYBase, 0.0f, sUsingRules); STATICHASH(PixelYStep); const float YStep = ConfigManager::GetFloat(sPixelYStep, 0.0f, sUsingRules); STATICHASH(Column0PixelX); const float Column0X = ConfigManager::GetFloat(sColumn0PixelX, 0.0f, sUsingRules); STATICHASH(Column1PixelX); const float Column1X = ConfigManager::GetFloat(sColumn1PixelX, 0.0f, sUsingRules); #if DEBUG_SETRES PRINTF("UIScreenEldSetRes info:\n"); PRINTF(" ScreenWidth: %d\n", pDisplay->m_ScreenWidth); PRINTF(" ScreenHeight: %d\n", pDisplay->m_ScreenHeight); #endif FOR_EACH_ARRAY_REVERSE(DisplayIter, DisplayModes, SDisplayMode) { const SDisplayMode& DisplayMode = DisplayIter.GetValue(); if (!pDisplay->m_Fullscreen && (DisplayMode.Width > pDisplay->m_ScreenWidth || DisplayMode.Height > pDisplay->m_ScreenHeight)) { #if DEBUG_SETRES PRINTF(" Skipping mode %dx%d:\n", DisplayMode.Width, DisplayMode.Height); #endif DisplayModes.FastRemove(DisplayIter); } } const int NumDisplayModes = static_cast<int>(DisplayModes.Size()); const int LeftColumnSize = (NumDisplayModes + 1) / 2; const int RightColumnSize = (NumDisplayModes + 1) - LeftColumnSize; // Add one for the Back button for (int DisplayModeIndex = 0; DisplayModeIndex < NumDisplayModes; ++DisplayModeIndex) { const SDisplayMode& DisplayMode = DisplayModes[DisplayModeIndex]; float ScreenX = 0.0f; float ScreenY = 0.0f; int FocusShiftUp = 0; int FocusShiftDown = 0; int FocusShiftLeft = 0; int FocusShiftRight = 0; if (DisplayModeIndex < LeftColumnSize) { // Display mode is in left column ScreenY = YBase + DisplayModeIndex * YStep; ScreenX = Column0X; FocusShiftLeft = -RightColumnSize; FocusShiftRight = LeftColumnSize; } else { // Display mode is in right column ScreenY = YBase + (DisplayModeIndex - LeftColumnSize) * YStep; ScreenX = Column1X; FocusShiftLeft = -LeftColumnSize; FocusShiftRight = RightColumnSize; } if (DisplayModeIndex == 0) { // Display mode is on top left FocusShiftUp = -(RightColumnSize + 1); } else if (DisplayModeIndex == (LeftColumnSize - 1)) { // Display mode is on bottom left FocusShiftDown = (RightColumnSize + 1); // If columns are the same size (*including* the back button), // this widget doesn't have a pair in the right column. if (LeftColumnSize == RightColumnSize) { // Setting focus override to 0 uses the screen's shift values, so loop // instead. FocusShiftLeft = -(NumDisplayModes + 1); FocusShiftRight = (NumDisplayModes + 1); } } else if (DisplayModeIndex == LeftColumnSize) { // Display mode is on top right left FocusShiftUp = -(LeftColumnSize + 1); } // Back button shift down is handled below this loop. const SimpleString NewDefinitionName = SimpleString::PrintF("_Res%d", DisplayModeIndex); // HACKHACK: Insert the UTF-8 codes for the U+00D7 (multiplication sign) const SimpleString ResolutionString = SimpleString::PrintF( "%d \xc3\x97 %d", DisplayMode.Width, DisplayMode.Height); MAKEHASH(NewDefinitionName); STATICHASH(UIWidgetType); ConfigManager::SetString(sUIWidgetType, "Text", sNewDefinitionName); ConfigManager::SetString(sArchetype, ArchetypeName, sNewDefinitionName); ConfigManager::SetString(sParent, Parent, sNewDefinitionName); STATICHASH(String); ConfigManager::SetString(sString, ResolutionString.CStr(), sNewDefinitionName); STATICHASH(PixelX); ConfigManager::SetFloat(sPixelX, ScreenX, sNewDefinitionName); STATICHASH(PixelY); ConfigManager::SetFloat(sPixelY, ScreenY, sNewDefinitionName); STATICHASH(FocusShiftUp); ConfigManager::SetInt(sFocusShiftUp, FocusShiftUp, sNewDefinitionName); STATICHASH(FocusShiftDown); ConfigManager::SetInt(sFocusShiftDown, FocusShiftDown, sNewDefinitionName); STATICHASH(FocusShiftLeft); ConfigManager::SetInt(sFocusShiftLeft, FocusShiftLeft, sNewDefinitionName); STATICHASH(FocusShiftRight); ConfigManager::SetInt(sFocusShiftRight, FocusShiftRight, sNewDefinitionName); UIWidget* const pResWidget = UIFactory::CreateWidget(NewDefinitionName, this); ASSERT(pResWidget); pResWidget->m_Callback = m_Callback; AddWidget(pResWidget); m_ResMap[NewDefinitionName] = DisplayMode; } STATIC_HASHED_STRING(SetResBackButton); UIWidget* const pBackButtonWidget = GetWidget(sSetResBackButton); ASSERT(pBackButtonWidget); pBackButtonWidget->m_FocusShiftLeft = -(NumDisplayModes + 1); pBackButtonWidget->m_FocusShiftRight = (NumDisplayModes + 1); pBackButtonWidget->m_FocusShiftDown = (LeftColumnSize + 1); UpdateRender(); // Initialize focus to the first element (so that we're never unfocused, // because that doesn't make sense for controllers). if (m_FocusWidgets.Size() > 0) { m_FocusedWidget = m_FocusWidgets[0]; // NOTE: Intentionally not calling SetFocus here, so effects don't happen; // we // just need an initial focus for controllers, it's not really *getting* // focus } }
void UIWidgetFrame::InitializeFromDefinition( const SimpleString& DefinitionName ) { UIWidget::InitializeFromDefinition( DefinitionName ); MAKEHASH( DefinitionName ); MAKEHASH( m_Archetype ); STATICHASH( DisplayWidth ); const float DisplayWidth = ConfigManager::GetFloat( sDisplayWidth ); const float ParentWidth = m_OriginParent ? m_OriginParent->GetWidth() : DisplayWidth; const float ParentX = m_OriginParent ? Ceiling( m_OriginParent->GetX() ) : 0.0f; STATICHASH( DisplayHeight ); const float DisplayHeight = ConfigManager::GetFloat( sDisplayHeight ); const float ParentHeight = m_OriginParent ? m_OriginParent->GetHeight() : DisplayHeight; const float ParentY = m_OriginParent ? Ceiling( m_OriginParent->GetY() ) : 0.0f; // "Screen" values are now relative to parent, which may or may not be screen dimensions. STATICHASH( PixelX ); STATICHASH( ScreenX ); float X = Pick( ConfigManager::GetArchetypeFloat( sPixelX, sm_Archetype, 0.0f, sDefinitionName ), ParentWidth * ConfigManager::GetArchetypeFloat( sScreenX, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelY ); STATICHASH( ScreenY ); float Y = Pick( ConfigManager::GetArchetypeFloat( sPixelY, sm_Archetype, 0.0f, sDefinitionName ), ParentHeight * ConfigManager::GetArchetypeFloat( sScreenY, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelWidth ); STATICHASH( ScreenWidth ); float Width = Pick( ConfigManager::GetArchetypeFloat( sPixelWidth, sm_Archetype, 0.0f, sDefinitionName ), ParentWidth * ConfigManager::GetArchetypeFloat( sScreenWidth, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelHeight ); STATICHASH( ScreenHeight ); float Height = Pick( ConfigManager::GetArchetypeFloat( sPixelHeight, sm_Archetype, 0.0f, sDefinitionName ), ParentHeight * ConfigManager::GetArchetypeFloat( sScreenHeight, sm_Archetype, 0.0f, sDefinitionName ) ); STATICHASH( PixelBorder ); m_Border = ConfigManager::GetArchetypeFloat( sPixelBorder, sm_Archetype, 0.0f, sDefinitionName ); // Adjust for desired aspect ratio if one dimension is not given // (This is used to size images using ScreenWidth or ScreenHeight // properly regardless of screen aspect ratio. STATICHASH( AspectRatio ); const float AspectRatio = ConfigManager::GetArchetypeFloat( sAspectRatio, sm_Archetype, 1.0f, sDefinitionName ); if( Width == 0.0f ) { Width = Height * AspectRatio; } else if( Height == 0.0f ) { Height = Width / AspectRatio; } AdjustDimensionsToParent( X, Y, Width, Height, ParentX, ParentY, ParentWidth, ParentHeight ); GetPositionFromOrigin( X, Y, Width, Height ); ASSERT( Width > m_Border * 2.0f ); ASSERT( Height > m_Border * 2.0f ); STATICHASH( ClampToPixelGrid ); if( ConfigManager::GetArchetypeBool( sClampToPixelGrid, sm_Archetype, true, sDefinitionName ) ) { m_TopLeft.x = Round( m_TopLeft.x ); m_TopLeft.y = Round( m_TopLeft.y ); } // Offset to properly align on pixel grid. const float PixelGridOffset = GetPixelGridOffset(); m_TopLeft.x -= PixelGridOffset; m_TopLeft.y -= PixelGridOffset; STATICHASH( Image ); const char* const Filename = ConfigManager::GetArchetypeString( sImage, sm_Archetype, DEFAULT_TEXTURE, sDefinitionName ); m_Texture = m_UIManager->GetRenderer()->GetTextureManager()->GetTexture( Filename, TextureManager::ETL_Permanent ); m_Dimensions = Vector2( Width, Height ); STATICHASH( MaterialOverride ); const SimpleString DefaultMaterial( "Material_HUD" ); m_Material = ConfigManager::GetArchetypeString( sMaterialOverride, sm_Archetype, DefaultMaterial.CStr(), sDefinitionName ); UpdateRender(); }