| 241 | } |
| 242 | |
| 243 | void CharCreationPane::changed() { |
| 244 | auto& root = Root::singleton(); |
| 245 | |
| 246 | auto textBox = fetchChild<TextBoxWidget>("name"); |
| 247 | auto speciesDefinition = Root::singleton().speciesDatabase()->species(m_speciesList[m_speciesChoice]); |
| 248 | auto species = speciesDefinition->options(); |
| 249 | auto genderOptions = species.genderOptions.wrap(m_genderChoice); |
| 250 | int genderIdx = pmod<int64_t>(m_genderChoice, species.genderOptions.size()); |
| 251 | |
| 252 | auto labels = speciesDefinition->charGenTextLabels(); |
| 253 | |
| 254 | fetchChild<LabelWidget>("labelMainSkinColor")->setText(labels[0]); |
| 255 | fetchChild<LabelWidget>("labelHairStyle")->setText(labels[1]); |
| 256 | fetchChild<LabelWidget>("labelShirt")->setText(labels[2]); |
| 257 | fetchChild<LabelWidget>("labelPants")->setText(labels[3]); |
| 258 | if (!labels[4].empty()) { |
| 259 | fetchChild<LabelWidget>("labelAlty")->setText(labels[4]); |
| 260 | fetchChild<LabelWidget>("labelAlty")->show(); |
| 261 | fetchChild<Widget>("alty")->show(); |
| 262 | } else { |
| 263 | fetchChild<LabelWidget>("labelAlty")->hide(); |
| 264 | fetchChild<Widget>("alty")->hide(); |
| 265 | } |
| 266 | fetchChild<LabelWidget>("labelHeady")->setText(labels[5]); |
| 267 | fetchChild<LabelWidget>("labelShirtColor")->setText(labels[6]); |
| 268 | fetchChild<LabelWidget>("labelPantsColor")->setText(labels[7]); |
| 269 | fetchChild<LabelWidget>("labelPortrait")->setText(labels[8]); |
| 270 | fetchChild<LabelWidget>("labelPersonality")->setText(labels[9]); |
| 271 | |
| 272 | if (auto speciesButton = fetchChild<ButtonWidget>(strf("species.{}", m_speciesChoice))) |
| 273 | speciesButton->check(); |
| 274 | if (auto genderButton = fetchChild<ButtonWidget>(strf("gender.{}", genderIdx))) |
| 275 | genderButton->check(); |
| 276 | |
| 277 | auto modeButton = fetchChild<ButtonWidget>(strf("mode.{}", m_modeChoice)); |
| 278 | modeButton->check(); |
| 279 | setLabel("labelMode", modeButton->data().getString("description", "fail")); |
| 280 | |
| 281 | // Update the gender images for the new species |
| 282 | for (size_t i = 0; i < species.genderOptions.size(); i++) |
| 283 | if (auto button = fetchChild<ButtonWidget>(strf("gender.{}", i))) |
| 284 | button->setOverlayImage(species.genderOptions[i].image); |
| 285 | |
| 286 | for (auto const& nameDefPair : root.speciesDatabase()->allSpecies()) { |
| 287 | String name; |
| 288 | SpeciesDefinitionPtr def; |
| 289 | std::tie(name, def) = nameDefPair; |
| 290 | // NOTE: Probably not hot enough to matter, but this contains and indexOf makes this loop |
| 291 | // O(n^2). This is less than ideal. |
| 292 | if (m_speciesList.contains(name)) { |
| 293 | if (auto bw = fetchChild<ButtonWidget>(strf("species.{}", m_speciesList.indexOf(name)))) |
| 294 | bw->setOverlayImage(def->options().genderOptions[genderIdx].characterImage); |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | auto portrait = fetchChild<PortraitWidget>("charPreview"); |
| 299 | if (fetchChild<ButtonWidget>("btnToggleClothing")->isChecked()) |
| 300 | portrait->setMode(PortraitMode::Full); |
nothing calls this directly
no test coverage detected