* Initializes all the elements in the Mod Options window. * @param game Pointer to the core game. * @param origin Game section that originated this state. */
| 39 | * @param origin Game section that originated this state. |
| 40 | */ |
| 41 | OptionsModsState::OptionsModsState(Game *game, OptionsOrigin origin) : OptionsBaseState(game, origin) |
| 42 | { |
| 43 | setCategory(_btnMods); |
| 44 | |
| 45 | // Create objects |
| 46 | _lstMods = new TextList(200, 136, 94, 8); |
| 47 | |
| 48 | add(_lstMods); |
| 49 | |
| 50 | centerAllSurfaces(); |
| 51 | |
| 52 | // how much room do we need for YES/NO |
| 53 | Text text = Text(100, 9, 0, 0); |
| 54 | text.initText(_game->getResourcePack()->getFont("FONT_BIG"), _game->getResourcePack()->getFont("FONT_SMALL"), _game->getLanguage()); |
| 55 | text.setText(tr("STR_YES")); |
| 56 | int yes = text.getTextWidth(); |
| 57 | text.setText(tr("STR_NO")); |
| 58 | int no = text.getTextWidth(); |
| 59 | |
| 60 | int rightcol = std::max(yes, no) + 2; |
| 61 | int leftcol = _lstMods->getWidth() - rightcol; |
| 62 | |
| 63 | // Set up objects |
| 64 | _lstMods->setAlign(ALIGN_RIGHT, 1); |
| 65 | _lstMods->setColumns(2, leftcol, rightcol); |
| 66 | _lstMods->setColor(Palette::blockOffset(8)+10); |
| 67 | _lstMods->setArrowColor(Palette::blockOffset(8) + 5); |
| 68 | _lstMods->setWordWrap(true); |
| 69 | _lstMods->setSelectable(true); |
| 70 | _lstMods->setBackground(_window); |
| 71 | _lstMods->onMouseClick((ActionHandler)&OptionsModsState::lstModsClick); |
| 72 | _lstMods->setTooltip("STR_MODS_DESC"); |
| 73 | _lstMods->onMouseIn((ActionHandler)&OptionsModsState::txtTooltipIn); |
| 74 | _lstMods->onMouseOut((ActionHandler)&OptionsModsState::txtTooltipOut); |
| 75 | |
| 76 | std::vector<std::string> rulesets = CrossPlatform::getDataContents("Ruleset/", "rul"); |
| 77 | for (std::vector<std::string>::iterator i = rulesets.begin(); i != rulesets.end(); ++i) |
| 78 | { |
| 79 | std::string mod = CrossPlatform::noExt(*i); |
| 80 | std::wstring modName = Language::fsToWstr(mod); |
| 81 | Language::replace(modName, L"_", L" "); |
| 82 | // ignore default ruleset |
| 83 | if (mod != "Xcom1Ruleset") |
| 84 | { |
| 85 | bool modEnabled = (std::find(Options::rulesets.begin(), Options::rulesets.end(), mod) != Options::rulesets.end()); |
| 86 | _lstMods->addRow(2, modName.c_str(), (modEnabled ? tr("STR_YES").c_str() : tr("STR_NO").c_str())); |
| 87 | _mods.push_back(mod); |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * |
nothing calls this directly
no test coverage detected