void UICharcreation::buttonpressed(uint16_t id) { switch (id) { case BT_CHARC_OK: if (named) { std::string cname = namechar.gettext(); uint16_t cjob = 1; int32_t cface = faces[female][face]; int32_t chair = hairs[female][hair]; uint8_t chairc = haircolors[female][haircolor]; uint8_t cskin = skins[female][skin]; int32_t ctop = tops[female][top]; int32_t cbot = bots[female][bot]; int32_t cshoe = shoes[female][shoe]; int32_t cwep = weapons[female][weapon]; CreateCharPacket(cname, cjob, cface, chair, chairc, cskin, ctop, cbot, cshoe, cwep, female).dispatch(); } else { std::string name = namechar.gettext(); if (name.size() >= 4) { namechar.setstate(Textfield::NORMAL); UI::get().disable(); UI::get().focustextfield(nullptr); NameCharPacket(name).dispatch(); } else { UI::get().add(ElementTag<UILoginNotice, int8_t>(10)); buttons[id]->setstate(Button::NORMAL); } } break; case BT_CHARC_CANCEL: if (named) { buttons[BT_CHARC_OK]->setposition(Point<int16_t>(482, 292)); buttons[BT_CHARC_CANCEL]->setposition(Point<int16_t>(555, 292)); buttons[BT_CHARC_FACEL]->setactive(false); buttons[BT_CHARC_FACER]->setactive(false); buttons[BT_CHARC_HAIRL]->setactive(false); buttons[BT_CHARC_HAIRR]->setactive(false); buttons[BT_CHARC_HAIRCL]->setactive(false); buttons[BT_CHARC_HAIRCR]->setactive(false); buttons[BT_CHARC_SKINL]->setactive(false); buttons[BT_CHARC_SKINR]->setactive(false); buttons[BT_CHARC_TOPL]->setactive(false); buttons[BT_CHARC_TOPR]->setactive(false); buttons[BT_CHARC_BOTL]->setactive(false); buttons[BT_CHARC_BOTR]->setactive(false); buttons[BT_CHARC_SHOESL]->setactive(false); buttons[BT_CHARC_SHOESR]->setactive(false); buttons[BT_CHARC_WEPL]->setactive(false); buttons[BT_CHARC_WEPR]->setactive(false); buttons[BT_CHARC_GENDERL]->setactive(false); buttons[BT_CHARC_GEMDERR]->setactive(false); buttons[BT_CHARC_CANCEL]->setstate(Button::NORMAL); namechar.setstate(Textfield::NORMAL); named = false; } else { active = false; UI::get().remove(CHARSELECT); UI::get().add(ElementTag<UICharSelect>()); } break; } if (id >= BT_CHARC_FACEL && id <= BT_CHARC_GEMDERR) { switch (id) { case BT_CHARC_FACEL: face = (face > 0) ? face - 1 : faces[female].size() - 1; newchar.setface(faces[female][face]); facename.settext(newchar.getfacetype()->getname()); break; case BT_CHARC_FACER: face = (face < faces[female].size() - 1) ? face + 1 : 0; newchar.setface(faces[female][face]); facename.settext(newchar.getfacetype()->getname()); break; case BT_CHARC_HAIRL: hair = (hair > 0) ? hair - 1 : hairs[female].size() - 1; newchar.sethair(hairs[female][hair] + haircolors[female][haircolor]); hairname.settext(newchar.gethairstyle()->getname()); break; case BT_CHARC_HAIRR: hair = (hair < hairs[female].size() - 1) ? hair + 1 : 0; newchar.sethair(hairs[female][hair] + haircolors[female][haircolor]); hairname.settext(newchar.gethairstyle()->getname()); break; case BT_CHARC_HAIRCL: haircolor = (haircolor > 0) ? haircolor - 1 : haircolors[female].size() - 1; newchar.sethair(hairs[female][hair] + haircolors[female][haircolor]); haircname.settext(newchar.gethairstyle()->getcolor()); break; case BT_CHARC_HAIRCR: haircolor = (haircolor < haircolors[female].size() - 1) ? haircolor + 1 : 0; newchar.sethair(hairs[female][hair] + haircolors[female][haircolor]); haircname.settext(newchar.gethairstyle()->getcolor()); break; case BT_CHARC_SKINL: skin = (skin > 0) ? skin - 1 : skins[female].size() - 1; newchar.setbody(skins[female][skin]); bodyname.settext(newchar.getbodytype()->getname()); break; case BT_CHARC_SKINR: skin = (skin < skins[female].size() - 1) ? skin + 1 : 0; newchar.setbody(skins[female][skin]); bodyname.settext(newchar.getbodytype()->getname()); break; case BT_CHARC_TOPL: top = (top > 0) ? top - 1 : tops[female].size() - 1; newchar.addequip(tops[female][top]); topname.settext(newchar.getequips().getequipname(Equipslot::TOP)); break; case BT_CHARC_TOPR: top = (top < tops[female].size() - 1) ? top + 1 : 0; newchar.addequip(tops[female][top]); topname.settext(newchar.getequips().getequipname(Equipslot::TOP)); break; case BT_CHARC_BOTL: bot = (bot > 0) ? bot - 1 : bots[female].size() - 1; newchar.addequip(bots[female][bot]); botname.settext(newchar.getequips().getequipname(Equipslot::PANTS)); break; case BT_CHARC_BOTR: bot = (bot < bots[female].size() - 1) ? bot + 1 : 0; newchar.addequip(bots[female][bot]); botname.settext(newchar.getequips().getequipname(Equipslot::PANTS)); break; case BT_CHARC_SHOESL: shoe = (shoe > 0) ? shoe - 1 : shoes[female].size() - 1; newchar.addequip(shoes[female][shoe]); shoename.settext(newchar.getequips().getequipname(Equipslot::SHOES)); break; case BT_CHARC_SHOESR: shoe = (shoe < shoes[female].size() - 1) ? shoe + 1 : 0; newchar.addequip(shoes[female][shoe]); shoename.settext(newchar.getequips().getequipname(Equipslot::SHOES)); break; case BT_CHARC_WEPL: weapon = (weapon > 0) ? weapon - 1 : weapons[female].size() - 1; newchar.addequip(weapons[female][weapon]); wepname.settext(newchar.getequips().getequipname(Equipslot::WEAPON)); break; case BT_CHARC_WEPR: weapon = (weapon < weapons[female].size() - 1) ? weapon + 1 : 0; newchar.addequip(weapons[female][weapon]); wepname.settext(newchar.getequips().getequipname(Equipslot::WEAPON)); break; case BT_CHARC_GENDERL: case BT_CHARC_GEMDERR: female = !female; randomizelook(); break; } buttons[id]->setstate(Button::MOUSEOVER); } }
Button::State UICharcreation::button_pressed(uint16_t id) { switch (id) { case BT_CHARC_OK: if (named) { std::string cname = namechar.get_text(); uint16_t cjob = 1; int32_t cface = faces[female][face]; int32_t chair = hairs[female][hair]; uint8_t chairc = haircolors[female][haircolor]; uint8_t cskin = skins[female][skin]; int32_t ctop = tops[female][top]; int32_t cbot = bots[female][bot]; int32_t cshoe = shoes[female][shoe]; int32_t cwep = weapons[female][weapon]; CreateCharPacket(cname, cjob, cface, chair, chairc, cskin, ctop, cbot, cshoe, cwep, female).dispatch(); return Button::PRESSED; } else { std::string name = namechar.get_text(); if (name.size() >= 4) { namechar.set_state(Textfield::NORMAL); UI::get().disable(); UI::get().focus_textfield(nullptr); NameCharPacket(name).dispatch(); return Button::PRESSED; } else { UI::get().emplace<UILoginNotice>(UILoginNotice::ILLEGAL_NAME); return Button::NORMAL; } } case BT_CHARC_CANCEL: if (named) { buttons[BT_CHARC_OK]->set_position({ 482, 292 }); buttons[BT_CHARC_CANCEL]->set_position({ 555, 292 }); buttons[BT_CHARC_FACEL]->set_active(false); buttons[BT_CHARC_FACER]->set_active(false); buttons[BT_CHARC_HAIRL]->set_active(false); buttons[BT_CHARC_HAIRR]->set_active(false); buttons[BT_CHARC_HAIRCL]->set_active(false); buttons[BT_CHARC_HAIRCR]->set_active(false); buttons[BT_CHARC_SKINL]->set_active(false); buttons[BT_CHARC_SKINR]->set_active(false); buttons[BT_CHARC_TOPL]->set_active(false); buttons[BT_CHARC_TOPR]->set_active(false); buttons[BT_CHARC_BOTL]->set_active(false); buttons[BT_CHARC_BOTR]->set_active(false); buttons[BT_CHARC_SHOESL]->set_active(false); buttons[BT_CHARC_SHOESR]->set_active(false); buttons[BT_CHARC_WEPL]->set_active(false); buttons[BT_CHARC_WEPR]->set_active(false); buttons[BT_CHARC_GENDERL]->set_active(false); buttons[BT_CHARC_GEMDERR]->set_active(false); buttons[BT_CHARC_CANCEL]->set_state(Button::NORMAL); namechar.set_state(Textfield::NORMAL); named = false; return Button::NORMAL; } else { active = false; if (auto charselect = UI::get().get_element<UICharSelect>()) charselect->makeactive(); return Button::PRESSED; } } if (id >= BT_CHARC_FACEL && id <= BT_CHARC_GEMDERR) { switch (id) { case BT_CHARC_FACEL: face = (face > 0) ? face - 1 : faces[female].size() - 1; newchar.set_face(faces[female][face]); facename.change_text(newchar.get_face()->get_name()); break; case BT_CHARC_FACER: face = (face < faces[female].size() - 1) ? face + 1 : 0; newchar.set_face(faces[female][face]); facename.change_text(newchar.get_face()->get_name()); break; case BT_CHARC_HAIRL: hair = (hair > 0) ? hair - 1 : hairs[female].size() - 1; newchar.set_hair(hairs[female][hair] + haircolors[female][haircolor]); hairname.change_text(newchar.get_hair()->get_name()); break; case BT_CHARC_HAIRR: hair = (hair < hairs[female].size() - 1) ? hair + 1 : 0; newchar.set_hair(hairs[female][hair] + haircolors[female][haircolor]); hairname.change_text(newchar.get_hair()->get_name()); break; case BT_CHARC_HAIRCL: haircolor = (haircolor > 0) ? haircolor - 1 : haircolors[female].size() - 1; newchar.set_hair(hairs[female][hair] + haircolors[female][haircolor]); haircname.change_text(newchar.get_hair()->getcolor()); break; case BT_CHARC_HAIRCR: haircolor = (haircolor < haircolors[female].size() - 1) ? haircolor + 1 : 0; newchar.set_hair(hairs[female][hair] + haircolors[female][haircolor]); haircname.change_text(newchar.get_hair()->getcolor()); break; case BT_CHARC_SKINL: skin = (skin > 0) ? skin - 1 : skins[female].size() - 1; newchar.set_body(skins[female][skin]); bodyname.change_text(newchar.get_body()->get_name()); break; case BT_CHARC_SKINR: skin = (skin < skins[female].size() - 1) ? skin + 1 : 0; newchar.set_body(skins[female][skin]); bodyname.change_text(newchar.get_body()->get_name()); break; case BT_CHARC_TOPL: top = (top > 0) ? top - 1 : tops[female].size() - 1; newchar.add_equip(tops[female][top]); topname.change_text(get_equipname(Equipslot::TOP)); break; case BT_CHARC_TOPR: top = (top < tops[female].size() - 1) ? top + 1 : 0; newchar.add_equip(tops[female][top]); topname.change_text(get_equipname(Equipslot::TOP)); break; case BT_CHARC_BOTL: bot = (bot > 0) ? bot - 1 : bots[female].size() - 1; newchar.add_equip(bots[female][bot]); botname.change_text(get_equipname(Equipslot::PANTS)); break; case BT_CHARC_BOTR: bot = (bot < bots[female].size() - 1) ? bot + 1 : 0; newchar.add_equip(bots[female][bot]); botname.change_text(get_equipname(Equipslot::PANTS)); break; case BT_CHARC_SHOESL: shoe = (shoe > 0) ? shoe - 1 : shoes[female].size() - 1; newchar.add_equip(shoes[female][shoe]); shoename.change_text(get_equipname(Equipslot::SHOES)); break; case BT_CHARC_SHOESR: shoe = (shoe < shoes[female].size() - 1) ? shoe + 1 : 0; newchar.add_equip(shoes[female][shoe]); shoename.change_text(get_equipname(Equipslot::SHOES)); break; case BT_CHARC_WEPL: weapon = (weapon > 0) ? weapon - 1 : weapons[female].size() - 1; newchar.add_equip(weapons[female][weapon]); wepname.change_text(get_equipname(Equipslot::WEAPON)); break; case BT_CHARC_WEPR: weapon = (weapon < weapons[female].size() - 1) ? weapon + 1 : 0; newchar.add_equip(weapons[female][weapon]); wepname.change_text(get_equipname(Equipslot::WEAPON)); break; case BT_CHARC_GENDERL: case BT_CHARC_GEMDERR: female = !female; randomize_look(); break; } return Button::MOUSEOVER; } return Button::PRESSED; }