1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-06-13 20:04:07 +00:00

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

View File

@ -614,7 +614,9 @@ namespace dialog {
if(reaction) reaction(); if(reaction) reaction();
if(ne.intval) *ne.editwhat = *ne.intval; if(ne.intval) *ne.editwhat = *ne.intval;
ne.s = disp(*ne.editwhat); ne.s = disp(*ne.editwhat);
#if CAP_ANIMATIONS
anims::deanimate(*ne.editwhat); anims::deanimate(*ne.editwhat);
#endif
} }
void use_hexeditor() { void use_hexeditor() {
@ -630,7 +632,9 @@ namespace dialog {
if(ne.sc.positive && x <= 0) return; if(ne.sc.positive && x <= 0) return;
*ne.editwhat = x; *ne.editwhat = x;
if(ne.intval) *ne.intval = ldtoint(*ne.editwhat); 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); if(ne.animatable) anims::animate_parameter(*ne.editwhat, ne.s, reaction ? reaction : reaction_final);
#endif
if(reaction) reaction(); if(reaction) reaction();
} }
@ -802,7 +806,9 @@ namespace dialog {
extra_options = reaction_t(); extra_options = reaction_t();
numberdark = 0; numberdark = 0;
ne.animatable = true; ne.animatable = true;
#if CAP_ANIMATIONS
anims::get_parameter_animation(x, ne.s); anims::get_parameter_animation(x, ne.s);
#endif
} }
void editNumber(int& x, int vmin, int vmax, int step, int dft, string title, string help) { 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); int expansion_hook = addHook(hooks_handleKey, 0, expansion_handleKey);
#if !CAP_MINI #if !ISMINI
void compute_coefficients() { void compute_coefficients() {
printf("%s %s\n", gp::operation_name().c_str(), ginf[geometry].tiling_name); printf("%s %s\n", gp::operation_name().c_str(), ginf[geometry].tiling_name);
start_game(); start_game();

View File

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

28
hyper.h
View File

@ -1910,6 +1910,7 @@ void clearMessages();
void resetGeometry(); void resetGeometry();
namespace shot { namespace shot {
#if CAP_SHOT
extern int shotx, shoty, shotformat; extern int shotx, shoty, shotformat;
extern bool make_svg; extern bool make_svg;
extern ld gamma, fade; extern ld gamma, fade;
@ -1918,16 +1919,25 @@ namespace shot {
void menu(); void menu();
void default_screenshot_content(); void default_screenshot_content();
void take(string fname, const function<void()>& what = default_screenshot_content); void take(string fname, const function<void()>& what = default_screenshot_content);
#endif
} }
#if CAP_SVG
namespace svg { namespace svg {
void circle(int x, int y, int size, color_t col, color_t fillcolor, double linewidth); 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 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); void text(int x, int y, int size, const string& str, bool frame, color_t col, int align);
extern bool in; extern bool in;
extern string link; extern string link;
#if CAP_SHOT
void render(const string& fname, const function<void()>& what = shot::default_screenshot_content); 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; 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 cell *shpos[MAXPLAYER][SHSIZE];
extern int cshpos; extern int cshpos;
#if CAP_ANIMATIONS
namespace anims { namespace anims {
void animate_parameter(ld &x, string f, const reaction_t& r); void animate_parameter(ld &x, string f, const reaction_t& r);
void deanimate(ld &x); void deanimate(ld &x);
void get_parameter_animation(ld &x, string& f); void get_parameter_animation(ld &x, string& f);
extern ld a, b; extern ld a, b;
} }
#endif
namespace arg { namespace arg {
#if CAP_COMMANDLINE #if CAP_COMMANDLINE
@ -2189,7 +2201,11 @@ namespace arg {
bool argis(const string& s); bool argis(const string& s);
unsigned arghex(); 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); void init(int _argc, char **_argv);
@ -4487,6 +4503,7 @@ ld atan2_auto(ld x);
ld atan2(hyperpoint h); ld atan2(hyperpoint h);
namespace anims { namespace anims {
#if CAP_ANIMATIONS
void apply(); void apply();
void rollback(); void rollback();
void show(); void show();
@ -4498,12 +4515,21 @@ namespace anims {
extern int noframes; extern int noframes;
extern ld period, cycle_length, parabolic_length, rug_angle, circle_radius, circle_spins; 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 { namespace startanims {
extern reaction_t current; extern reaction_t current;
void pick(); void pick();
} }
#endif
extern int animation_lcm; extern int animation_lcm;
extern ld animation_factor; extern ld animation_factor;

View File

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

View File

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

View File

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

View File

@ -3,15 +3,9 @@
namespace hr { namespace hr {
#if ISMOBILE==1
namespace svg {
bool in = false;
}
#endif
bool hide_hud = true; bool hide_hud = true;
#if ISMOBILE==0 #if CAP_SVG
// svg renderer // svg renderer
namespace svg { namespace svg {
#if ISWEB #if ISWEB
@ -185,7 +179,7 @@ namespace svg {
#endif #endif
} }
#if CAP_COMMANDLINE #if CAP_COMMANDLINE && CAP_SHOT
int read_args() { int read_args() {
using namespace arg; using namespace arg;
if(argis("-svgsize")) { if(argis("-svgsize")) {
@ -1081,6 +1075,7 @@ void spin_around() {
reaction_t add_to_frame; reaction_t add_to_frame;
#if CAP_STARTANIM
void draw_ghost(const transmatrix V, int id) { void draw_ghost(const transmatrix V, int id) {
if(id % 13 == 0) { if(id % 13 == 0) {
queuepoly(V, shMiniGhost, 0xFFFF00C0); queuepoly(V, shMiniGhost, 0xFFFF00C0);
@ -1177,6 +1172,7 @@ void pick() {
} }
auto sanimhook = addHook(hooks_frame, 100, []() { if(add_to_frame) add_to_frame(); }); 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 #define CAP_BT CAP_GEOMETRY
#endif #endif
#ifndef CAP_STARTANIM
#define CAP_STARTANIM (!(ISMINI))
#endif
#ifndef CAP_FIELD #ifndef CAP_FIELD
#define CAP_FIELD (!(ISMINI)) #define CAP_FIELD (!(ISMINI))
#endif #endif

View File

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