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

Method GraphsState

src/Geoscape/GraphsState.cpp:55–307  ·  view source on GitHub ↗

* Initializes all the elements in the Graphs screen. * @param game Pointer to the core game. */

Source from the content-addressed store, hash-verified

53 * @param game Pointer to the core game.
54 */
55GraphsState::GraphsState(Game *game) : State(game), _butRegionsOffset(0), _butCountriesOffset(0)
56{
57 // Create objects
58 _bg = new InteractiveSurface(320, 200, 0, 0);
59 _bg->onMousePress((ActionHandler)&GraphsState::shiftButtons, SDL_BUTTON_WHEELUP);
60 _bg->onMousePress((ActionHandler)&GraphsState::shiftButtons, SDL_BUTTON_WHEELDOWN);
61 _btnUfoRegion = new InteractiveSurface(32, 24, 96, 0);
62 _btnUfoCountry = new InteractiveSurface(32, 24, 128, 0);
63 _btnXcomRegion = new InteractiveSurface(32, 24, 160, 0);
64 _btnXcomCountry = new InteractiveSurface(32, 24, 192, 0);
65 _btnIncome = new InteractiveSurface(32, 24, 224, 0);
66 _btnFinance = new InteractiveSurface(32, 24, 256, 0);
67 _btnGeoscape = new InteractiveSurface(32, 24, 288, 0);
68 _txtTitle = new Text(220, 16, 100, 28);
69 _txtFactor = new Text(38, 11, 96, 28);
70 _txtMonths = new TextList(205, 8, 115, 183);
71 _txtYears = new TextList(200, 8, 121, 191);
72
73 // Set palette
74 setPalette("PAL_GRAPHS");
75
76 //add all our elements
77 add(_bg);
78 add(_btnUfoRegion);
79 add(_btnUfoCountry);
80 add(_btnXcomRegion);
81 add(_btnXcomCountry);
82 add(_btnIncome);
83 add(_btnFinance);
84 add(_btnGeoscape);
85 add(_txtMonths);
86 add(_txtYears);
87 add(_txtTitle);
88 add(_txtFactor);
89 for (int scaleText = 0; scaleText != 10; ++scaleText)
90 {
91 _txtScale.push_back(new Text(42, 16, 80, 171 - (scaleText*14)));
92 add(_txtScale.at(scaleText));
93 }
94
95 //create buttons (sooooo many buttons)
96 size_t offset = 0;
97 for (std::vector<Region *>::iterator iter = _game->getSavedGame()->getRegions()->begin(); iter != _game->getSavedGame()->getRegions()->end(); ++iter)
98 {
99 // always save in toggles all the regions
100 _regionToggles.push_back(new GraphButInfo(tr((*iter)->getRules()->getType()) , -42 + (4*offset)));
101 // initially add the GRAPH_MAX_BUTTONS having the first regions information
102 if(offset < GRAPH_MAX_BUTTONS)
103 {
104 _btnRegions.push_back(new ToggleTextButton(80, 11, 0, offset*11));
105 _btnRegions.at(offset)->setColor(Palette::blockOffset(9)+7);
106 _btnRegions.at(offset)->setInvertColor(-42 + (4*offset));
107 _btnRegions.at(offset)->setText(tr((*iter)->getRules()->getType()));
108 _btnRegions.at(offset)->onMousePress((ActionHandler)&GraphsState::btnRegionListClick);
109 _btnRegions.at(offset)->onMousePress((ActionHandler)&GraphsState::shiftButtons, SDL_BUTTON_WHEELUP);
110 _btnRegions.at(offset)->onMousePress((ActionHandler)&GraphsState::shiftButtons, SDL_BUTTON_WHEELDOWN);
111 add(_btnRegions.at(offset));
112 }

Callers

nothing calls this directly

Calls 15

onMousePressMethod · 0.80
getRegionsMethod · 0.80
getSavedGameMethod · 0.80
setInvertColorMethod · 0.80
getCountriesMethod · 0.80
setPressedMethod · 0.80
drawRectMethod · 0.80
getMonthMethod · 0.80
setColumnsMethod · 0.80
addRowMethod · 0.80
setRowColorMethod · 0.80
getYearMethod · 0.80

Tested by

no test coverage detected