CAP_ animations etc. cleanup

This commit is contained in:
? 2019-02-17 18:43:39 +01:00 committed by Zeno Rogue
parent 99aa7e420b
commit e39777f04d
11 changed files with 73 additions and 20 deletions

View File

@ -317,6 +317,7 @@ void initConfig() {
#if CAP_FILES && CAP_SHOT
addsaver(anims::animfile, "animation file format");
#endif
#if CAP_ANIMATIONS
addsaver(anims::period, "animation period");
addsaver(anims::noframes, "animation frames");
addsaver(anims::cycle_length, "animation cycle length");
@ -324,6 +325,7 @@ void initConfig() {
addsaver(anims::rug_angle, "animation rug angle");
addsaver(anims::circle_radius, "animation circle radius");
addsaver(anims::circle_spins, "animation circle spins");
#endif
#if CAP_CRYSTAL
addsaver(crystal::compass_probability, "compass-probability");
@ -1962,15 +1964,17 @@ unordered_map<string, ld&> params = {
{"stretch", vid.stretch},
{"twopoint", vid.twopoint_param},
{"bwidth", vid.binary_width},
#if CAP_ANIMATIONS
{"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},
#endif
{"mobius", vid.skiprope},
{"sang", conformal::spiral_angle},
{"spiralx", conformal::spiral_x},
{"spiraly", conformal::spiral_y},

View File

@ -614,7 +614,9 @@ namespace dialog {
if(reaction) reaction();
if(ne.intval) *ne.editwhat = *ne.intval;
ne.s = disp(*ne.editwhat);
#if CAP_ANIMATIONS
anims::deanimate(*ne.editwhat);
#endif
}
void use_hexeditor() {
@ -630,7 +632,9 @@ namespace dialog {
if(ne.sc.positive && x <= 0) return;
*ne.editwhat = x;
if(ne.intval) *ne.intval = ldtoint(*ne.editwhat);
#if CAP_ANIMATIONS
if(ne.animatable) anims::animate_parameter(*ne.editwhat, ne.s, reaction ? reaction : reaction_final);
#endif
if(reaction) reaction();
}
@ -802,7 +806,9 @@ namespace dialog {
extra_options = reaction_t();
numberdark = 0;
ne.animatable = true;
#if CAP_ANIMATIONS
anims::get_parameter_animation(x, ne.s);
#endif
}
void editNumber(int& x, int vmin, int vmax, int step, int dft, string title, string help) {

View File

@ -751,7 +751,7 @@ bool expansion_handleKey(int sym, int uni) {
int expansion_hook = addHook(hooks_handleKey, 0, expansion_handleKey);
#if !CAP_MINI
#if !ISMINI
void compute_coefficients() {
printf("%s %s\n", gp::operation_name().c_str(), ginf[geometry].tiling_name);
start_game();

View File

@ -66,7 +66,9 @@ int main(int argc, char **argv) {
#endif
#if !ISWEB
if(showstartmenu && !vid.skipstart) {
#if CAP_STARTANIM
startanims::pick();
#endif
pushScreen(showStartMenu);
}
#endif

28
hyper.h
View File

@ -1910,6 +1910,7 @@ void clearMessages();
void resetGeometry();
namespace shot {
#if CAP_SHOT
extern int shotx, shoty, shotformat;
extern bool make_svg;
extern ld gamma, fade;
@ -1918,16 +1919,25 @@ namespace shot {
void menu();
void default_screenshot_content();
void take(string fname, const function<void()>& what = default_screenshot_content);
#endif
}
#if CAP_SVG
namespace svg {
void circle(int x, int y, int size, color_t col, color_t fillcolor, double linewidth);
void polygon(int *polyx, int *polyy, int polyi, color_t col, color_t outline, double linewidth);
void text(int x, int y, int size, const string& str, bool frame, color_t col, int align);
extern bool in;
extern string link;
#if CAP_SHOT
void render(const string& fname, const function<void()>& what = shot::default_screenshot_content);
#endif
}
#else
namespace svg {
static const always_false in;
}
#endif
extern int sightrange_bonus, genrange_bonus, gamerange_bonus;
@ -2168,12 +2178,14 @@ int darkena(int c, int lev, int a);
extern cell *shpos[MAXPLAYER][SHSIZE];
extern int cshpos;
#if CAP_ANIMATIONS
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;
}
#endif
namespace arg {
#if CAP_COMMANDLINE
@ -2189,7 +2201,11 @@ namespace arg {
bool argis(const string& s);
unsigned arghex();
inline void shift_arg_formula(ld& x, const reaction_t& r = reaction_t()) { shift(); x = argf(); anims::animate_parameter(x, args(), r); }
inline void shift_arg_formula(ld& x, const reaction_t& r = reaction_t()) { shift(); x = argf();
#if CAP_ANIMATIONS
anims::animate_parameter(x, args(), r);
#endif
}
void init(int _argc, char **_argv);
@ -4487,6 +4503,7 @@ ld atan2_auto(ld x);
ld atan2(hyperpoint h);
namespace anims {
#if CAP_ANIMATIONS
void apply();
void rollback();
void show();
@ -4498,12 +4515,21 @@ namespace anims {
extern int noframes;
extern ld period, cycle_length, parabolic_length, rug_angle, circle_radius, circle_spins;
#else
static bool any_on() { return false; }
static void rollback() { }
static bool center_music() { return false; }
static bool any_animation() { return false; }
static void apply() { }
#endif
}
#if CAP_STARTANIM
namespace startanims {
extern reaction_t current;
void pick();
}
#endif
extern int animation_lcm;
extern ld animation_factor;

View File

@ -1082,9 +1082,11 @@ void optimizeview() {
subscreen_split(optimizeview);
#if CAP_ANIMATIONS
if(centerover.at && inmirror(centerover.at)) {
anims::reflect_view();
}
#endif
DEBB(DF_GRAPH, (debugfile,"optimize view\n"));
int turn = 0;

View File

@ -267,7 +267,10 @@ void showMainMenu() {
else if(uni == 'd') pushScreen(showDisplayMode);
else if(uni == 'm') pushScreen(showChangeMode);
else if(uni == 'R') dialog::do_if_confirmed([] {
popScreenAll(), startanims::pick(), pushScreen(showStartMenu);
#if CAP_STARTANIM
startanims::pick();
#endif
popScreenAll(), pushScreen(showStartMenu);
});
#if CAP_SAVE
else if(uni == 't') scores::load();
@ -408,8 +411,10 @@ void showDisplayMode() {
#endif
else if(uni == 'a')
pushScreen(conformal::model_menu);
#if CAP_ANIMATIONS
else if(uni == 'A')
pushScreen(anims::show);
#endif
#if CAP_MODEL
else if(xuni == 'n')
@ -624,7 +629,9 @@ void showStartMenu() {
daily_mode = 20;
}
#if CAP_STARTANIM
startanims::current();
#endif
getcstat = ' ';
@ -841,7 +848,9 @@ void showStartMenu() {
clearMessages();
welcomeMessage();
}
#if CAP_STARTANIM
else if(sym == SDLK_F5) startanims::pick();
#endif
};
}

View File

@ -1253,20 +1253,21 @@ void dqi_line::draw() {
}
void dqi_string::draw() {
#if ISMOBILE==0
if(svg::in)
#if CAP_SVG
if(svg::in) {
svg::text(x, y, size, str, frame, color, align);
else {
int fr = frame & 255;
displayfrSP(x, y, shift, fr, size, str, color, align, frame >> 8);
return;
}
#elseif ISMOBILE==0
int fr = frame & 255;
displayfrSP(x, y, shift, fr, size, str, color, align, frame >> 8);
#else
displayfr(x, y, frame, size, str, color, align);
#endif
}
void dqi_circle::draw() {
#if ISMOBILE==0
#if CAP_SVG
if(svg::in) {
svg::circle(x, y, size, color, fillcolor, linewidth);
}

View File

@ -3,15 +3,9 @@
namespace hr {
#if ISMOBILE==1
namespace svg {
bool in = false;
}
#endif
bool hide_hud = true;
#if ISMOBILE==0
#if CAP_SVG
// svg renderer
namespace svg {
#if ISWEB
@ -184,8 +178,8 @@ namespace svg {
fclose(f.f); f.f = NULL;
#endif
}
#if CAP_COMMANDLINE
#if CAP_COMMANDLINE && CAP_SHOT
int read_args() {
using namespace arg;
if(argis("-svgsize")) {
@ -1081,6 +1075,7 @@ void spin_around() {
reaction_t add_to_frame;
#if CAP_STARTANIM
void draw_ghost(const transmatrix V, int id) {
if(id % 13 == 0) {
queuepoly(V, shMiniGhost, 0xFFFF00C0);
@ -1177,6 +1172,7 @@ void pick() {
}
auto sanimhook = addHook(hooks_frame, 100, []() { if(add_to_frame) add_to_frame(); });
#endif
}
}

View File

@ -467,6 +467,10 @@ union SDL_Event;
#define CAP_BT CAP_GEOMETRY
#endif
#ifndef CAP_STARTANIM
#define CAP_STARTANIM (!(ISMINI))
#endif
#ifndef CAP_FIELD
#define CAP_FIELD (!(ISMINI))
#endif

View File

@ -231,6 +231,7 @@ cld exp_parser::parse(int prio) {
else { std::stringstream ss; res = 0; ss << number; ss >> res; }
}
while(true) {
#if CAP_ANIMATIONS
if(next() == '.' && next(1) == '.' && prio == 0) {
vector<cld> rest = { res };
while(next() == '.' && next(1) == '.') {
@ -243,7 +244,9 @@ cld exp_parser::parse(int prio) {
res = rest[vf] + (rest[vf+1] - rest[vf]) * v;
return res;
}
else if(next() == '+' && prio <= 10) at++, res = res + parse(20);
else
#endif
if(next() == '+' && prio <= 10) at++, res = res + parse(20);
else if(next() == '-' && prio <= 10) at++, res = res - parse(20);
else if(next() == '*' && prio <= 20) at++, res = res * parse(30);
else if(next() == '/' && prio <= 20) at++, res = res / parse(30);