Add ability to edit changeling characters.
This commit is contained in:
parent
255b55c8de
commit
c35ac19060
|
@ -20,6 +20,28 @@ struct FormStateContext<'a> {
|
||||||
pub selected_system: &'a CharacterDataType,
|
pub selected_system: &'a CharacterDataType,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn edit_character_template(user: &User, character: Character) -> Result<Template, Error> {
|
||||||
|
let character = character.uprade()?;
|
||||||
|
|
||||||
|
let context = EditCharacterContext {
|
||||||
|
name: &character.character_name,
|
||||||
|
username: &user.username,
|
||||||
|
data_type: &character.data_type,
|
||||||
|
sheet: character.dyn_deserialize()?,
|
||||||
|
state: FormStateContext {
|
||||||
|
selected_system: &character.data_type,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
use CharacterDataType::*;
|
||||||
|
let template = match character.data_type {
|
||||||
|
ChroniclesOfDarknessV1 => Template::render("characters/edit_character", context),
|
||||||
|
ChangelingV1 => Template::render("characters/edit_changeling_character", context),
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(template)
|
||||||
|
}
|
||||||
|
|
||||||
#[get("/<owner>/<character_id>/edit")]
|
#[get("/<owner>/<character_id>/edit")]
|
||||||
pub(super) async fn edit_character_page(
|
pub(super) async fn edit_character_page(
|
||||||
character_id: i32,
|
character_id: i32,
|
||||||
|
@ -39,15 +61,6 @@ pub(super) async fn edit_character_page(
|
||||||
return Err(Error::NoPermission);
|
return Err(Error::NoPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
let context = EditCharacterContext {
|
let template = edit_character_template(logged_in_user, character)?;
|
||||||
name: &character.character_name,
|
Ok(template)
|
||||||
username: &owner.username,
|
|
||||||
data_type: &character.data_type,
|
|
||||||
sheet: character.dyn_deserialize()?,
|
|
||||||
state: FormStateContext {
|
|
||||||
selected_system: &character.data_type,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Template::render("characters/edit_character", context))
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,134 @@
|
||||||
|
{% import "characters/edit_character_macros" as macros %}
|
||||||
|
{% extends "base" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<style type="text/css">
|
||||||
|
body {
|
||||||
|
font-family: Liberation Sans, Arial;
|
||||||
|
}
|
||||||
|
|
||||||
|
#attributes {
|
||||||
|
padding: 4px;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
#attributes .attributes-section {
|
||||||
|
border: 1px solid gray;
|
||||||
|
border-collapse: collapse;
|
||||||
|
display: table-cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attribute {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attribute label {
|
||||||
|
display: inline-block;
|
||||||
|
float: left;
|
||||||
|
clear: left;
|
||||||
|
width: 10em;
|
||||||
|
text-align: right;
|
||||||
|
vertical-align: text-bottom;
|
||||||
|
padding: 8px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.attribute input {
|
||||||
|
max-width: 4em;
|
||||||
|
display: inline-block;
|
||||||
|
float: left;
|
||||||
|
padding: 8px;
|
||||||
|
border: none;
|
||||||
|
background-color: lightgray;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#skills {
|
||||||
|
padding: 4px;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
#skills .skills-section {
|
||||||
|
border: 1px solid gray;
|
||||||
|
border-collapse: collapse;
|
||||||
|
display: table-cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skill {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skill label {
|
||||||
|
display: inline-block;
|
||||||
|
float: left;
|
||||||
|
clear: left;
|
||||||
|
width: 10em;
|
||||||
|
text-align: right;
|
||||||
|
vertical-align: text-bottom;
|
||||||
|
padding: 8px;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.skill input {
|
||||||
|
max-width: 4em;
|
||||||
|
display: inline-block;
|
||||||
|
float: left;
|
||||||
|
padding: 8px;
|
||||||
|
border: none;
|
||||||
|
background-color: lightgray;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/protobufjs@6.10.2/dist/protobuf.min.js"></script>
|
||||||
|
<script defer type="text/javascript" src="/scripts/api.js"></script>
|
||||||
|
<script defer type="text/javascript" src="/scripts/characters/edit.js"></script>
|
||||||
|
<h1>Core Sheet</h1>
|
||||||
|
<div>
|
||||||
|
<h1>Name: <input type="text" value="{{name}}" /></h1>
|
||||||
|
<p>System: {{data_type}}</p>
|
||||||
|
<div id="attributes">
|
||||||
|
<div class="attributes-section" id="mentalAttributes">
|
||||||
|
{{ macros::attribute(name="Intelligence", value=sheet.base.intelligence) }}
|
||||||
|
{{ macros::attribute(name="Wits", value=sheet.base.wits) }}
|
||||||
|
{{ macros::attribute(name="Resolve", value=sheet.base.resolve) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="attributes-section" id="physicalAttributes">
|
||||||
|
{{ macros::attribute(name="Strength", value=sheet.base.strength) }}
|
||||||
|
{{ macros::attribute(name="Dexterity", value=sheet.base.dexterity) }}
|
||||||
|
{{ macros::attribute(name="Stamina", value=sheet.base.stamina) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="attributes-section" id="socicalAttributes">
|
||||||
|
{{ macros::attribute(name="Presence", value=sheet.base.presence) }}
|
||||||
|
{{ macros::attribute(name="Manipulation", value=sheet.base.manipulation) }}
|
||||||
|
{{ macros::attribute(name="Composure", value=sheet.base.composure) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="skills">
|
||||||
|
<div class="skills-section" id="mentalSkills">
|
||||||
|
{% for skill_name, skill in sheet.base.mentalSkills %}
|
||||||
|
{{ macros::skill(name=skill_name, value=skill.dots) }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="skills-section" id="physicalSkills">
|
||||||
|
{% for skill_name, skill in sheet.base.physicalSkills %}
|
||||||
|
{{ macros::skill(name=skill_name, value=skill.dots) }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="skills-section" id="socialSkills">
|
||||||
|
{% for skill_name, skill in sheet.base.socialSkills %}
|
||||||
|
{{ macros::skill(name=skill_name, value=skill.dots) }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
Loading…
Reference in New Issue