mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-10-31 19:36:16 +00:00
dialog:: new options for matrix dialog
This commit is contained in:
parent
392d3c075f
commit
e666faba31
74
dialogs.cpp
74
dialogs.cpp
@ -1124,29 +1124,77 @@ EX namespace dialog {
|
|||||||
transmatrix *edit_matrix;
|
transmatrix *edit_matrix;
|
||||||
int dim;
|
int dim;
|
||||||
void draw() override;
|
void draw() override;
|
||||||
|
void large_viz();
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void matrix_dialog::large_viz() {
|
||||||
|
addCustom(500, [this] {
|
||||||
|
int siz = dfsize * 5;
|
||||||
|
int mid = (top + tothei) / 2;
|
||||||
|
visualize_matrix(*edit_matrix, dcenter, mid, siz/2, dim);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void matrix_dialog::draw() {
|
void matrix_dialog::draw() {
|
||||||
cmode = dialogflags;
|
cmode = dialogflags;
|
||||||
gamescreen();
|
gamescreen();
|
||||||
init(title);
|
init(title);
|
||||||
addInfo(help);
|
addInfo(help);
|
||||||
addCustom(500, [this] {
|
large_viz();
|
||||||
int siz = dfsize * 5;
|
|
||||||
int mid = (top + tothei) / 2;
|
|
||||||
visualize_matrix(*edit_matrix, dcenter, mid, siz/2, dim);
|
|
||||||
});
|
|
||||||
addBreak(100);
|
addBreak(100);
|
||||||
addItem("enter angle", 'a');
|
addItem("reset", 'r');
|
||||||
|
dialog::add_action([this] { *edit_matrix = Id; });
|
||||||
|
if(dim == 2) {
|
||||||
|
static ld angle;
|
||||||
|
angle = as_degrees(*edit_matrix);
|
||||||
|
addSelItem("enter angle", fts(angle), 'a');
|
||||||
|
dialog::add_action([this] {
|
||||||
|
editNumber(angle, -180, 180, 90, 0, title, help);
|
||||||
|
auto& ne = get_ne();
|
||||||
|
auto re = reaction;
|
||||||
|
ne.extra_options = [this] { large_viz(); };
|
||||||
|
ne.reaction = [re, this] { *edit_matrix = spin(angle * degree); if(re) re(); };
|
||||||
|
ne.reaction_final = reaction;
|
||||||
|
ne.animatable = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(dim == 3) {
|
||||||
|
transmatrix cur = *edit_matrix;
|
||||||
|
auto rot_but = [this, cur] (int i, int j, string title, char key) {
|
||||||
|
addItem(title, key);
|
||||||
|
dialog::add_action([i, j, title, this, cur] {
|
||||||
|
static ld angle; angle = 0;
|
||||||
|
editNumber(angle, -180, 180, 90, 0, title, XLAT("Angle to rotate by."));
|
||||||
|
auto& ne = get_ne();
|
||||||
|
auto re = reaction;
|
||||||
|
ne.extra_options = [this] { large_viz(); };
|
||||||
|
ne.reaction = [re, i, j, this, cur] { *edit_matrix = cspin(i, j, angle * degree) * cur; if(re) re(); };
|
||||||
|
ne.reaction_final = reaction;
|
||||||
|
ne.animatable = false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
rot_but(0, 1, "rotate in XY", 'z');
|
||||||
|
rot_but(0, 2, "rotate in XZ", 'y');
|
||||||
|
rot_but(1, 2, "rotate in YZ", 'x');
|
||||||
|
}
|
||||||
|
static string formula;
|
||||||
|
formula = "?";
|
||||||
|
anims::get_parameter_animation(anims::find_param(edit_matrix), formula);
|
||||||
|
addSelItem("enter formula", formula, 'f');
|
||||||
dialog::add_action([this] {
|
dialog::add_action([this] {
|
||||||
static ld angle = as_degrees(*edit_matrix);
|
if(formula == "?") formula = "id";
|
||||||
editNumber(angle, -180, 180, 90, 0, title, help);
|
anims::get_parameter_animation(anims::find_param(edit_matrix), formula);
|
||||||
auto& ne = get_ne();
|
dialog::edit_string(formula, "formula", XLAT("dxy(n) = rotate n degrees from x to y\n\nd-degree, r-radian, t-turn\n\nexample: dxy(30)*dyz(45)"));
|
||||||
auto re = reaction;
|
dialog::get_di().extra_options = [this] { large_viz(); };
|
||||||
ne.reaction = [re, this] { *edit_matrix = spin(angle * degree); if(re) re(); };
|
dialog::get_di().reaction = [this] {
|
||||||
ne.reaction_final = reaction;
|
try {
|
||||||
ne.animatable = false;
|
*edit_matrix = parsematrix(formula);
|
||||||
|
auto p = anims::find_param(edit_matrix);
|
||||||
|
if(p) p->load_as_animation(formula);
|
||||||
|
}
|
||||||
|
catch(hr_parse_exception&) { }
|
||||||
|
};
|
||||||
});
|
});
|
||||||
addBack();
|
addBack();
|
||||||
display();
|
display();
|
||||||
|
Loading…
Reference in New Issue
Block a user