added notes and improved visuals

This commit is contained in:
Lukas Forsberg 2025-06-07 19:53:54 +02:00
parent e13de7c786
commit 0ab7c52cfc
3 changed files with 26 additions and 15 deletions

View File

@ -5,19 +5,20 @@
using namespace std; using namespace std;
HtmxShAttributeList::HtmxShAttributeList(const std::string& id, const vector<string>& itemList, std::map<std::string, std::string>& data){ HtmxShAttributeList::HtmxShAttributeList(const std::string& id, const vector<string>& itemList, std::map<std::string, std::string>& data){
html += "<div class='section'>";
html += format("<h2>{}</h2>", id); html += format("<h2>{}</h2>", id);
html += "<div class='grid'>"; html += "<div class='grid_at'>";
for (auto& item : itemList){ for (auto& item : itemList){
string item_id = utils::to_id_format(format("{}_{}", id, item)); string item_id = utils::to_id_format(format("{}_{}", id, item));
auto value = data.contains(item_id) ? data[item_id] : ""; auto value = data.contains(item_id) ? data[item_id] : "";
html += format("<label>{}:<input type='text' name='{}' value='{}'></label>", item, item_id, value); html += format("<label>{}<input type='text' name='{}' value='{}'></label>", item, item_id, value);
} }
html += "</div>"; html += "</div></div>";
} }
HtmxShAttributeList::HtmxShAttributeList(const std::string& id, const std::vector<std::pair<std::string, std::string>>& itemValueList){ HtmxShAttributeList::HtmxShAttributeList(const std::string& id, const std::vector<std::pair<std::string, std::string>>& itemValueList){
html += format("<h2>{}</h2>", id); html += format("<h2>{}</h2>", id);
html += "<div class='grid'>"; html += "<div class='grid_at'>";
for (auto& item : itemValueList){ for (auto& item : itemValueList){
string item_id = utils::to_id_format(format("{}_{}", id, item)); string item_id = utils::to_id_format(format("{}_{}", id, item));
html += format("<label>{}:<input type='text' name='{}' value='{}'></label>", item, item_id, item.second); html += format("<label>{}:<input type='text' name='{}' value='{}'></label>", item, item_id, item.second);

View File

@ -16,10 +16,10 @@ static const vector<string> cCharacterInfo = {
"Nuyen", "Nuyen",
"Lifestyle", "Lifestyle",
"Total Karma", "Total Karma",
"Current Karma", "C. Karma",
"Street Cred", "Street Cred",
"Notoriety", "Notoriety",
"Public Awareness" "Fame"
}; };
static const vector<string> cAttributes = { static const vector<string> cAttributes = {
@ -104,9 +104,10 @@ static const vector<string> genFormIds(){
HtmxShCondition::genIds(vec, "Stun Condition", 12); HtmxShCondition::genIds(vec, "Stun Condition", 12);
HtmxShItemList::genIds(vec, "Contacts", cContactsParameters, 6); HtmxShItemList::genIds(vec, "Contacts", cContactsParameters, 6);
HtmxShItemList::genIds(vec, "Ranged Weapons", cRangedWeaponsParameters, 7); HtmxShItemList::genIds(vec, "Ranged Weapons", cRangedWeaponsParameters, 7);
HtmxShItemList::genIds(vec, "Cyberware and Bioware", cImplantParameters, 9); HtmxShItemList::genIds(vec, "Cyberware and Bioware", cImplantParameters, 18);
HtmxShItemList::genIds(vec, "Melee Weapons", cMeleeWeaponParameters, 7); HtmxShItemList::genIds(vec, "Melee Weapons", cMeleeWeaponParameters, 7);
HtmxShItemList::genIds(vec, "Armor", cArmorParamters , 3); HtmxShItemList::genIds(vec, "Armor", cArmorParamters , 3);
vec.push_back("notes");
return vec; return vec;
} }
@ -116,12 +117,11 @@ const std::vector<std::string> ShadowrunCharacterForm::m_checkboxIds = genCheckb
ShadowrunCharacterForm::ShadowrunCharacterForm(std::map<std::string, std::string>& data) { ShadowrunCharacterForm::ShadowrunCharacterForm(std::map<std::string, std::string>& data) {
html.reserve(30000); html.reserve(30000);
html += "<form hx-post='/api/shadowrun/submit-character' hx-target='#form-response' hx-swap='innerHTML'>"; html += "<form hx-post='/api/shadowrun/submit-character' hx-target='#form-response' hx-swap='innerHTML'>";
html += "<div style='display: grid; grid-template-columns: 1fr 1fr; gap: 2em;'>";
html += HtmxShAttributeList("Character Info", cCharacterInfo, data).htmx(); html += HtmxShAttributeList("Character Info", cCharacterInfo, data).htmx();
html += HtmxShAttributeList("Attributes", cAttributes, data).htmx(); html += HtmxShAttributeList("Attributes", cAttributes, data).htmx();
html += "<div style='display: grid; grid-template-columns: 1fr 1fr; gap: 2em;'>";
html += HtmxShItemList("Active Skills", cSkillParameters, 8, data).htmx(); html += HtmxShItemList("Active Skills", cSkillParameters, 8, data).htmx();
html += HtmxShItemList("Knowledge Skills", cSkillParameters, 8, data).htmx(); html += HtmxShItemList("Knowledge Skills", cSkillParameters, 8, data).htmx();
@ -152,11 +152,16 @@ ShadowrunCharacterForm::ShadowrunCharacterForm(std::map<std::string, std::string
html += HtmxShCondition("Stun Condition", 12, data).htmx(); html += HtmxShCondition("Stun Condition", 12, data).htmx();
html += HtmxShItemList("Contacts", cContactsParameters, 6, data).htmx(); html += HtmxShItemList("Contacts", cContactsParameters, 6, data).htmx();
html += HtmxShItemList("Ranged Weapons", cRangedWeaponsParameters, 7, data).htmx(); html += HtmxShItemList("Ranged Weapons", cRangedWeaponsParameters, 7, data).htmx();
html += HtmxShItemList("Cyberware and Bioware", cImplantParameters, 9, data).htmx(); html += HtmxShItemList("Cyberware and Bioware", cImplantParameters, 18, data).htmx();
html += HtmxShItemList("Melee Weapons", cMeleeWeaponParameters, 7, data).htmx(); html += HtmxShItemList("Melee Weapons", cMeleeWeaponParameters, 7, data).htmx();
html += HtmxShItemList("Armor", cArmorParamters , 3, data).htmx(); html += HtmxShItemList("Armor", cArmorParamters , 3, data).htmx();
html += "</div>"; html += "</div>";
valueNotes = data.contains("notes") ? data["notes"] : "";
html += format("<div style='margin-top: 1em;'><label for='notes'>Notes:</label>"
"<textarea id='notes' name='notes' rows='100' style='width:100%; resize:vertical; overflow:auto;'>{}</textarea></div>", valueNotes);
html += "<div style='text-align:center'>" html += "<div style='text-align:center'>"
"<button type='submit'>Submit</button>" "<button type='submit'>Submit</button>"
"</div>" "</div>"

View File

@ -27,26 +27,31 @@
padding-bottom: 0.5em; padding-bottom: 0.5em;
} }
.grid { .grid_at {
display: grid; display: grid;
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
gap: 1em; gap: 1em;
} }
.grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
}
.grid-2 { .grid-2 {
grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(2, 1fr);
} }
.grid-3 { .grid-3 {
grid-template-columns: repeat(3, 1fr); grid-template-columns: 2fr 1fr 1fr;
} }
.grid-4 { .grid-4 {
grid-template-columns: repeat(4, 1fr); grid-template-columns: 2fr 1fr 1fr 1fr;
} }
.grid-6 { .grid-6 {
grid-template-columns: repeat(6, 1fr); grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr;
} }
.skill-row { .skill-row {