Commit a604192c authored by twanvl's avatar twanvl

use font settings for drawing multiple choice text labels, spacing and direction are scriptable.

parent fa706786
...@@ -39,6 +39,12 @@ IMPLEMENT_REFLECTION(MultipleChoiceStyle) { ...@@ -39,6 +39,12 @@ IMPLEMENT_REFLECTION(MultipleChoiceStyle) {
REFLECT(spacing); REFLECT(spacing);
} }
int MultipleChoiceStyle::update(Context& ctx) {
return ChoiceStyle::update(ctx)
| direction.update(ctx) * CHANGE_OTHER
| spacing.update(ctx) * CHANGE_OTHER;
}
// ----------------------------------------------------------------------------- : MultipleChoiceValue // ----------------------------------------------------------------------------- : MultipleChoiceValue
IMPLEMENT_REFLECTION_NAMELESS(MultipleChoiceValue) { IMPLEMENT_REFLECTION_NAMELESS(MultipleChoiceValue) {
......
...@@ -36,8 +36,10 @@ class MultipleChoiceStyle : public ChoiceStyle { ...@@ -36,8 +36,10 @@ class MultipleChoiceStyle : public ChoiceStyle {
MultipleChoiceStyle(const MultipleChoiceFieldP& field); MultipleChoiceStyle(const MultipleChoiceFieldP& field);
DECLARE_STYLE_TYPE(MultipleChoice); DECLARE_STYLE_TYPE(MultipleChoice);
Direction direction; ///< In what direction are choices layed out? Scriptable<Direction> direction; ///< In what direction are choices layed out?
double spacing; ///< Spacing between choices (images) in pixels Scriptable<double> spacing; ///< Spacing between choices (images) in pixels
virtual int update(Context&);
}; };
// ----------------------------------------------------------------------------- : MultipleChoiceValue // ----------------------------------------------------------------------------- : MultipleChoiceValue
......
...@@ -3950,9 +3950,6 @@ ...@@ -3950,9 +3950,6 @@
<Filter <Filter
Name="template-stuff" Name="template-stuff"
Filter=""> Filter="">
<File
RelativePath="..\data\magic-test.mse-style\script-language-tests">
</File>
<Filter <Filter
Name="magic" Name="magic"
Filter=""> Filter="">
...@@ -3990,6 +3987,16 @@ ...@@ -3990,6 +3987,16 @@
RelativePath="..\data\magic.mse-game\word_lists"> RelativePath="..\data\magic.mse-game\word_lists">
</File> </File>
</Filter> </Filter>
<Filter
Name="test"
Filter="">
<File
RelativePath="..\data\magic-test.mse-style\script-language-tests">
</File>
<File
RelativePath="..\data\magic-test.mse-style\style">
</File>
</Filter>
</Filter> </Filter>
<File <File
RelativePath=".\code_template.cpp"> RelativePath=".\code_template.cpp">
......
...@@ -74,9 +74,10 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const ...@@ -74,9 +74,10 @@ void MultipleChoiceValueViewer::drawChoice(RotatedDC& dc, RealPoint& pos, const
if (style().render_style & RENDER_TEXT) { if (style().render_style & RENDER_TEXT) {
// draw text // draw text
String text = tr(getStylePackage(), choice, capitalize_sentence); String text = tr(getStylePackage(), choice, capitalize_sentence);
dc.SetFont(style().font,1);
RealSize text_size = dc.GetTextExtent(text); RealSize text_size = dc.GetTextExtent(text);
dc.DrawText(text, align_in_rect(ALIGN_MIDDLE_LEFT, text_size, RealPoint text_pos = align_in_rect(ALIGN_MIDDLE_LEFT, text_size, RealRect(pos.x + size.width + 1, pos.y, 0,size.height));
RealRect(pos + RealSize(size.width + 1, 0), RealSize(0,size.height)))); dc.DrawTextWithShadow(text, style().font, pos);
size = add_horizontal(size, text_size); size = add_horizontal(size, text_size);
} }
// next position // next position
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <gfx/color.hpp> #include <gfx/color.hpp>
Alignment from_string(const String&); Alignment from_string(const String&);
bool parse_enum(const String&,Direction&);
DECLARE_TYPEOF_COLLECTION(ScriptParseError); DECLARE_TYPEOF_COLLECTION(ScriptParseError);
...@@ -30,6 +31,7 @@ void store(const ScriptValueP& val, Defaultable<String>& var) { var.assign(*val) ...@@ -30,6 +31,7 @@ void store(const ScriptValueP& val, Defaultable<String>& var) { var.assign(*val)
void store(const ScriptValueP& val, Defaultable<Color>& var) { var.assign((AColor)*val); } void store(const ScriptValueP& val, Defaultable<Color>& var) { var.assign((AColor)*val); }
void store(const ScriptValueP& val, Defaultable<AColor>& var) { var.assign(*val); } void store(const ScriptValueP& val, Defaultable<AColor>& var) { var.assign(*val); }
void store(const ScriptValueP& val, Alignment& var) { var = from_string(val->toString()); } void store(const ScriptValueP& val, Alignment& var) { var = from_string(val->toString()); }
void store(const ScriptValueP& val, Direction& var) { parse_enum(val->toString(),var); }
// ----------------------------------------------------------------------------- : OptionalScript // ----------------------------------------------------------------------------- : OptionalScript
......
...@@ -33,6 +33,7 @@ void store(const ScriptValueP& val, AColor& var); ...@@ -33,6 +33,7 @@ void store(const ScriptValueP& val, AColor& var);
void store(const ScriptValueP& val, Defaultable<String>& var); void store(const ScriptValueP& val, Defaultable<String>& var);
void store(const ScriptValueP& val, Defaultable<Color>& var); void store(const ScriptValueP& val, Defaultable<Color>& var);
void store(const ScriptValueP& val, Alignment& var); void store(const ScriptValueP& val, Alignment& var);
void store(const ScriptValueP& val, Direction& var);
// ----------------------------------------------------------------------------- : OptionalScript // ----------------------------------------------------------------------------- : OptionalScript
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment