MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / populateResearchList

Method populateResearchList

game/ui/base/researchselect.cpp:212–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212void ResearchSelect::populateResearchList()
213{
214 auto research_list = form->findControlTyped<ListBox>("LIST");
215 research_list->clear();
216 research_list->ItemSize = 20;
217 research_list->ItemSpacing = 1;
218
219 for (auto &t : state->research.topic_list)
220 {
221 if (t->type != this->lab->type)
222 {
223 continue;
224 }
225 if ((!t->dependencies.satisfied(state->current_base) && t->started == false) || t->hidden)
226 {
227 continue;
228 }
229 // FIXME: When we get font coloring, set light blue color for topics too large a size
230 bool too_large = (t->required_lab_size == ResearchTopic::LabSize::Large &&
231 this->lab->size == ResearchTopic::LabSize::Small);
232 std::ignore = too_large;
233
234 auto control = mksp<Control>();
235 control->Size = {544, 20};
236
237 auto topic_name = control->createChild<Label>((t->name), ui().getFont("smalfont"));
238 topic_name->Size = {200, 18};
239 topic_name->Location = {6, 2};
240
241 if (this->lab->type == ResearchTopic::Type::Engineering ||
242 ((this->lab->type == ResearchTopic::Type::BioChem ||
243 this->lab->type == ResearchTopic::Type::Physics) &&
244 t->isComplete()))
245 {
246 UString progress_text;
247 if (this->lab->type == ResearchTopic::Type::Engineering)
248 progress_text = format("$%d", t->cost);
249 else
250 progress_text = tr("Complete");
251 auto progress_label =
252 control->createChild<Label>(progress_text, ui().getFont("smalfont"));
253 progress_label->Size = {100, 18};
254 progress_label->Location = {234, 2};
255 }
256 else
257 {
258 float projectProgress =
259 clamp((float)t->man_hours_progress / (float)t->man_hours, 0.0f, 1.0f);
260
261 auto progressBg = control->createChild<Graphic>(progressImage);
262 progressBg->Size = {102, 6};
263 progressBg->Location = {234, 6};
264 auto progressBar = control->createChild<Graphic>();
265 progressBar->Size = {101, 6};
266 progressBar->Location = {234, 6};
267
268 auto progressImage = mksp<RGBImage>(progressBar->Size);
269 int redWidth = progressBar->Size.x * projectProgress;

Callers 1

beginMethod · 0.95

Calls 13

formatFunction · 0.85
trFunction · 0.85
clampFunction · 0.85
satisfiedMethod · 0.80
isCompleteMethod · 0.80
getTotalSkillMethod · 0.80
setDataMethod · 0.80
clearMethod · 0.45
getFontMethod · 0.45
setMethod · 0.45
setImageMethod · 0.45
addItemMethod · 0.45

Tested by

no test coverage detected