| 106 | } |
| 107 | |
| 108 | void UI::Menu::initializeInstance(const std::string& instance) |
| 109 | { |
| 110 | // Load MENU.DAT in case this hasn't been done yet |
| 111 | if (!loadMenuDAT()) |
| 112 | return; |
| 113 | |
| 114 | // Create and initialize instance for this very menu |
| 115 | m_MenuHandle = m_pVM->getGameState().createMenu(); |
| 116 | |
| 117 | m_pVM->initializeInstance(ZMemory::toBigHandle(m_MenuHandle), |
| 118 | m_pVM->getDATFile().getSymbolIndexByName(instance), |
| 119 | Daedalus::IC_Menu); |
| 120 | |
| 121 | // Create background image first |
| 122 | m_pBackgroundImage = new ImageView(m_Engine); |
| 123 | m_pBackgroundImage->setTranslation(Math::float2(getScriptData().posx / 8192.0f, getScriptData().posy / 8192.0f)); |
| 124 | m_pBackgroundImage->setSize(Math::float2(getScriptData().dimx / 8192.0f, getScriptData().dimy / 8192.0f)); |
| 125 | |
| 126 | Handle::TextureHandle bgr = m_Engine.getEngineTextureAlloc().loadTextureVDF(getScriptData().backPic); |
| 127 | m_pBackgroundImage->setImage(bgr); |
| 128 | m_pBackgroundImage->setRelativeSize(false); // Scale like this screen |
| 129 | addChild(m_pBackgroundImage); |
| 130 | |
| 131 | // Create all other items drawn on top |
| 132 | m_Items = initializeItems(); |
| 133 | |
| 134 | if ((getScriptData().flags & Daedalus::GEngineClasses::C_Menu::MENU_SHOW_INFO) != 0) |
| 135 | { |
| 136 | m_pInfoText = new TextView(m_Engine); |
| 137 | addChild(m_pInfoText); |
| 138 | |
| 139 | float infoX = 1000.0f / 8192.0f; |
| 140 | float infoY = 7500.0f / 8192.0f; |
| 141 | |
| 142 | // There could be script-defined values |
| 143 | |
| 144 | if (m_pVM->getDATFile().hasSymbolName("MENU_INFO_X") && m_pVM->getDATFile().hasSymbolName("MENU_INFO_X")) |
| 145 | { |
| 146 | Daedalus::PARSymbol& symX = m_pVM->getDATFile().getSymbolByName("MENU_INFO_X"); |
| 147 | Daedalus::PARSymbol& symY = m_pVM->getDATFile().getSymbolByName("MENU_INFO_Y"); |
| 148 | |
| 149 | infoX = symX.getInt() / 8192.0f; |
| 150 | infoY = symY.getInt() / 8192.0f; |
| 151 | } |
| 152 | float sX = 1.0f - infoX * 2.0f; |
| 153 | float sY = 1.0f - infoY; |
| 154 | |
| 155 | infoX += sX / 2; |
| 156 | // infoY += sY / 2; |
| 157 | |
| 158 | m_pInfoText->setTranslation(Math::float2(infoX, infoY)); |
| 159 | m_pInfoText->setAlignment(A_TopCenter); |
| 160 | m_pInfoText->setFont(UI::DEFAULT_FONT); |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | bool UI::Menu::loadMenuDAT() |
| 165 | { |
no test coverage detected