MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / OptionsModsState

Method OptionsModsState

src/Menu/OptionsModsState.cpp:41–90  ·  view source on GitHub ↗

* Initializes all the elements in the Mod Options window. * @param game Pointer to the core game. * @param origin Game section that originated this state. */

Source from the content-addressed store, hash-verified

39 * @param origin Game section that originated this state.
40 */
41OptionsModsState::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 *

Callers

nothing calls this directly

Calls 15

getDataContentsFunction · 0.85
noExtFunction · 0.85
getLanguageMethod · 0.80
getTextWidthMethod · 0.80
setColumnsMethod · 0.80
onMouseClickMethod · 0.80
setTooltipMethod · 0.80
onMouseInMethod · 0.80
onMouseOutMethod · 0.80
addRowMethod · 0.80
TextClass · 0.70
initTextMethod · 0.45

Tested by

no test coverage detected