mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-23 21:07:17 +00:00
a/b parameters, and parameters referring to each other
This commit is contained in:
parent
ca6ed2eff2
commit
4ce6005597
49
config.cpp
49
config.cpp
@ -1762,4 +1762,53 @@ int read_gamemode_args() {
|
||||
auto ah_config = addHook(hooks_args, 0, read_config_args) + addHook(hooks_args, 0, read_gamemode_args);
|
||||
#endif
|
||||
|
||||
unordered_map<string, ld&> params = {
|
||||
{"linewidth", vid.linewidth},
|
||||
{"patternlinewidth", linepatterns::width},
|
||||
{"scale", vid.scale},
|
||||
{"xposition", vid.xposition},
|
||||
{"yposition", vid.yposition},
|
||||
{"projection", vid.alpha},
|
||||
{"sspeed", vid.sspeed},
|
||||
{"mspeed", vid.mspeed},
|
||||
{"ballangle", vid.ballangle},
|
||||
{"yshift", vid.yshift},
|
||||
{"cameraangle", vid.camera_angle},
|
||||
{"depth", geom3::depth},
|
||||
{"camera", geom3::camera},
|
||||
{"wall_height", geom3::wall_height},
|
||||
{"highdetail", geom3::highdetail},
|
||||
{"middetail", geom3::middetail},
|
||||
{"rock_wall_ratio", geom3::rock_wall_ratio},
|
||||
{"human_wall_ratio", geom3::human_wall_ratio},
|
||||
{"lake_top", geom3::lake_top},
|
||||
{"lake_bottom", geom3::lake_bottom},
|
||||
{"rug_model_distance", rug::model_distance},
|
||||
{"star", polygonal::STAR},
|
||||
{"lvspeed", conformal::lvspeed},
|
||||
{"rotation", conformal::rotation},
|
||||
{"mori", conformal::model_orientation},
|
||||
{"topz", conformal::top_z},
|
||||
{"mtrans", conformal::model_transition},
|
||||
{"hp", conformal::halfplane_scale},
|
||||
{"back", backbrightness},
|
||||
{"ipd", stereo::ipd},
|
||||
{"lr", stereo::lr_eyewidth},
|
||||
{"anaglyph", stereo::anaglyph_eyewidth},
|
||||
{"fov", stereo::fov},
|
||||
{"ets", vid.euclid_to_sphere},
|
||||
{"stretch", vid.stretch},
|
||||
{"twopoint", vid.twopoint_param},
|
||||
{"bwidth", vid.binary_width},
|
||||
{"aperiod", anims::period},
|
||||
{"acycle", anims::cycle_length},
|
||||
{"aparabolic", anims::parabolic_length},
|
||||
{"arugangle", anims::rug_angle},
|
||||
{"acradius", anims::circle_radius},
|
||||
{"acspins", anims::circle_spins},
|
||||
{"mobius", vid.skiprope},
|
||||
{"a", anims::a},
|
||||
{"b", anims::b},
|
||||
};
|
||||
|
||||
}
|
||||
|
3
hyper.h
3
hyper.h
@ -2061,6 +2061,7 @@ namespace anims {
|
||||
void animate_parameter(ld &x, string f, const reaction_t& r);
|
||||
void deanimate(ld &x);
|
||||
void get_parameter_animation(ld &x, string& f);
|
||||
extern ld a, b;
|
||||
}
|
||||
|
||||
namespace arg {
|
||||
@ -4353,5 +4354,7 @@ struct bandfixer {
|
||||
|
||||
inline void delayed_geo_reset() { need_reset_geometry = true; }
|
||||
|
||||
extern unordered_map<string, ld&> params;
|
||||
|
||||
}
|
||||
|
||||
|
@ -579,6 +579,25 @@ void animator(string caption, ld& param, char key) {
|
||||
});
|
||||
}
|
||||
|
||||
ld a, b;
|
||||
|
||||
void list_animated_parameters() {
|
||||
dialog::addHelp(XLAT(
|
||||
"Most parameters can be animated simply by using '..' in their editing dialog. "
|
||||
"For example, the value of a parameter set to 0..1 will grow linearly from 0 to 1. "
|
||||
"You can also use functions (e.g. cos(0..2*pi)) and refer to other parameters; "
|
||||
"parameters 'a' and 'b' exist for this purpose. "
|
||||
"See the list below for parameters which are currently animated (or changed)."));
|
||||
dialog::addBreak(50);
|
||||
for(auto& ap: aps) {
|
||||
string what = "?";
|
||||
for(auto& p: params) if(&p.second == ap.value) what = p.first;
|
||||
dialog::addInfo(what + " = " + ap.formula);
|
||||
}
|
||||
dialog::addBreak(50);
|
||||
dialog::addHelp(parser_help());
|
||||
}
|
||||
|
||||
ld animation_period;
|
||||
|
||||
void show() {
|
||||
@ -727,10 +746,17 @@ void show() {
|
||||
else if(among(pmodel, mdHyperboloid, mdHemisphere, mdBall))
|
||||
animator(XLAT("3D rotation"), ballangle_rotation, 'r');
|
||||
|
||||
/*
|
||||
animator(XLAT("animate parameter change"), anim_param, 'P');
|
||||
dialog::addSelItem(XLAT("choose parameters to animate"), its(paramstate), 'C');
|
||||
dialog::add_action(next_paramstate); */
|
||||
dialog::addSelItem(XLAT("animate parameters"), fts(a), 'a');
|
||||
dialog::add_action([] () {
|
||||
dialog::editNumber(a, -100, 100, 1, 0, XLAT("animate parameters"), "");
|
||||
dialog::extra_options = list_animated_parameters;
|
||||
});
|
||||
|
||||
dialog::addSelItem(XLAT("animate parameters"), fts(b), 'b');
|
||||
dialog::add_action([] () {
|
||||
dialog::editNumber(b, -100, 100, 1, 0, XLAT("animate parameters"), "");
|
||||
dialog::extra_options = list_animated_parameters;
|
||||
});
|
||||
|
||||
dialog::addBoolItem(XLAT("history mode"), (conformal::on || conformal::includeHistory), 'h');
|
||||
dialog::add_action([] () { pushScreen(conformal::history_menu); });
|
||||
|
3
util.cpp
3
util.cpp
@ -202,9 +202,10 @@ cld exp_parser::parse(int prio) {
|
||||
else if(number == "p" || number == "pi") res = M_PI;
|
||||
else if(number == "" && next() == '-') { at++; res = -parse(prio); }
|
||||
else if(number == "") at = -1;
|
||||
else if(extra_params.count(number)) res = extra_params[number];
|
||||
else if(number == "s") res = ticks / 1000.;
|
||||
else if(number == "ms") res = ticks;
|
||||
else if(extra_params.count(number)) res = extra_params[number];
|
||||
else if(params.count(number)) res = params.at(number);
|
||||
else if(number[0] >= 'a' && number[0] <= 'z') at = -1;
|
||||
else { std::stringstream ss; res = 0; ss << number; ss >> res; }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user