2018-07-19 21:46:58 +00:00
|
|
|
// Hyperbolic Rogue -- screenshots in SVG and PNG formats
|
|
|
|
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
|
|
|
|
|
|
|
|
namespace hr {
|
|
|
|
|
2019-02-06 15:34:42 +00:00
|
|
|
bool hide_hud = true;
|
|
|
|
|
2019-02-17 17:43:39 +00:00
|
|
|
#if CAP_SVG
|
2018-07-19 21:46:58 +00:00
|
|
|
// svg renderer
|
|
|
|
namespace svg {
|
2018-12-13 13:53:44 +00:00
|
|
|
#if ISWEB
|
|
|
|
shstream f;
|
|
|
|
#else
|
|
|
|
fhstream f;
|
|
|
|
#endif
|
|
|
|
|
2018-07-19 21:46:58 +00:00
|
|
|
bool in = false;
|
|
|
|
|
2018-09-04 17:53:42 +00:00
|
|
|
ld cta(color_t col) {
|
2018-07-19 21:46:58 +00:00
|
|
|
// col >>= 24;
|
|
|
|
col &= 0xFF;
|
|
|
|
return col / 255.0;
|
|
|
|
}
|
|
|
|
|
2018-09-04 17:53:42 +00:00
|
|
|
bool invisible(color_t col) { return (col & 0xFF) == 0; }
|
2018-07-19 21:46:58 +00:00
|
|
|
|
|
|
|
void fixgamma(unsigned int& color) {
|
|
|
|
unsigned char *c = (unsigned char*) (&color);
|
2018-12-13 12:33:08 +00:00
|
|
|
for(int i=1; i<4; i++) c[i] = 255 * pow(float(c[i] / 255.0), float(shot::gamma));
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int svgsize;
|
|
|
|
int divby = 10;
|
|
|
|
|
|
|
|
const char* coord(int val) {
|
|
|
|
static char buf[10][20];
|
|
|
|
static int id;
|
|
|
|
id++; id %= 10;
|
|
|
|
if(divby == 1) {
|
|
|
|
sprintf(buf[id], "%d", val); return buf[id];
|
|
|
|
}
|
|
|
|
else if(divby <= 10) {
|
|
|
|
sprintf(buf[id], "%.1f", val*1./divby); return buf[id];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sprintf(buf[id], "%.2f", val*1./divby); return buf[id];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-06 17:39:53 +00:00
|
|
|
char* stylestr(color_t fill, color_t stroke, ld width=1) {
|
2018-07-19 21:46:58 +00:00
|
|
|
fixgamma(fill);
|
|
|
|
fixgamma(stroke);
|
|
|
|
static char buf[600];
|
|
|
|
// printf("fill = %08X stroke = %08x\n", fill, stroke);
|
|
|
|
|
2018-11-01 18:03:11 +00:00
|
|
|
if(stroke == 0xFF00FF && false) {
|
2018-07-19 21:46:58 +00:00
|
|
|
stroke = 0x000000FF;
|
|
|
|
|
|
|
|
if(fill == 0x332a22ff) fill = 0x000000FF;
|
|
|
|
else if(fill == 0x686868FF) fill = 0x000000FF;
|
|
|
|
else if(fill == 0xd0d0d0FF) fill = 0x000000FF;
|
|
|
|
else fill = 0xFFFFFFFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(buf, "style=\"stroke:#%06x;stroke-opacity:%.3" PLDF ";stroke-width:%" PLDF "px;fill:#%06x;fill-opacity:%.3" PLDF "\"",
|
|
|
|
(stroke>>8) & 0xFFFFFF, cta(stroke),
|
|
|
|
width/divby,
|
|
|
|
(fill>>8) & 0xFFFFFF, cta(fill)
|
|
|
|
);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2018-12-13 16:03:39 +00:00
|
|
|
void circle(int x, int y, int size, color_t col, color_t fillcol, double linewidth) {
|
2018-11-09 19:50:08 +00:00
|
|
|
if(!invisible(col) || !invisible(fillcol)) {
|
2018-08-01 02:01:16 +00:00
|
|
|
if(vid.stretch == 1)
|
2018-12-13 16:03:39 +00:00
|
|
|
println(f, "<circle cx='", coord(x), "' cy='", coord(y), "' r='", coord(size), "' ", stylestr(fillcol, col, linewidth), "/>");
|
2018-08-01 02:01:16 +00:00
|
|
|
else
|
2018-12-13 13:53:44 +00:00
|
|
|
println(f, "<ellipse cx='", coord(x), "' cy='", coord(y), "' rx='", coord(size), "' ry='", coord(size*vid.stretch), "' ", stylestr(fillcol, col), "/>");
|
2018-08-01 02:01:16 +00:00
|
|
|
}
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 17:53:42 +00:00
|
|
|
string link;
|
2018-07-19 21:46:58 +00:00
|
|
|
|
|
|
|
void startstring() {
|
2018-12-13 13:53:44 +00:00
|
|
|
if(link != "") print(f, "<a xlink:href=\"", link, "\" xlink:show=\"replace\">");
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void stopstring() {
|
2018-12-13 13:53:44 +00:00
|
|
|
if(link != "") print(f, "</a>");
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
string font = "Times";
|
|
|
|
|
2018-09-04 17:53:42 +00:00
|
|
|
void text(int x, int y, int size, const string& str, bool frame, color_t col, int align) {
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-11-17 18:24:02 +00:00
|
|
|
double dfc = (x - current_display->xcenter) * (x - current_display->xcenter) +
|
|
|
|
(y - current_display->ycenter) * (y - current_display->ycenter);
|
|
|
|
dfc /= current_display->radius;
|
|
|
|
dfc /= current_display->radius;
|
2018-07-19 21:46:58 +00:00
|
|
|
// 0 = center, 1 = edge
|
|
|
|
dfc = 1 - dfc;
|
|
|
|
|
|
|
|
col = 0xFF + (col << 8);
|
|
|
|
|
|
|
|
bool uselatex = font == "latex";
|
|
|
|
|
|
|
|
if(!invisible(col)) {
|
|
|
|
startstring();
|
|
|
|
string str2 = "";
|
|
|
|
for(int i=0; i<(int) str.size(); i++)
|
|
|
|
if(str[i] == '&')
|
|
|
|
str2 += "&";
|
|
|
|
else if(str[i] == '<')
|
|
|
|
str2 += "<";
|
|
|
|
else if(str[i] == '>')
|
|
|
|
str2 += ">";
|
|
|
|
else if(uselatex && str[i] == '#')
|
|
|
|
str2 += "\\#";
|
|
|
|
else str2 += str[i];
|
|
|
|
if(uselatex) str2 = string("\\myfont{")+coord(size)+"}{" + str2 + "}";
|
2018-12-13 13:53:44 +00:00
|
|
|
|
|
|
|
print(f, "<text x='", coord(x), "' y='", coord(y+size*.4), "' text-anchor='", align == 8 ? "middle" :
|
2018-07-19 21:46:58 +00:00
|
|
|
align < 8 ? "start" :
|
2018-12-13 13:53:44 +00:00
|
|
|
"end", "' ");
|
2018-07-19 21:46:58 +00:00
|
|
|
if(!uselatex)
|
2018-12-13 13:53:44 +00:00
|
|
|
print(f, "font-family='", font, "' font-size='", coord(size), "' ");
|
|
|
|
print(f,
|
|
|
|
stylestr(col, frame ? 0x0000000FF : 0, (1<<get_sightrange())*dfc/40),
|
|
|
|
">", str2, "</text>");
|
2018-07-19 21:46:58 +00:00
|
|
|
stopstring();
|
2018-12-13 13:53:44 +00:00
|
|
|
println(f);
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-04 19:43:43 +00:00
|
|
|
void polygon(int *polyx, int *polyy, int polyi, color_t col, color_t outline, double linewidth) {
|
2018-07-19 21:46:58 +00:00
|
|
|
|
|
|
|
if(invisible(col) && invisible(outline)) return;
|
|
|
|
if(polyi < 2) return;
|
2018-10-28 02:06:31 +00:00
|
|
|
|
2018-07-19 21:46:58 +00:00
|
|
|
startstring();
|
|
|
|
for(int i=0; i<polyi; i++) {
|
|
|
|
if(i == 0)
|
2018-12-13 13:53:44 +00:00
|
|
|
print(f, "<path d=\"M ");
|
2018-07-19 21:46:58 +00:00
|
|
|
else
|
2018-12-13 13:53:44 +00:00
|
|
|
print(f, " L ");
|
|
|
|
print(f, coord(polyx[i]), " ", coord(polyy[i]));
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
|
2018-12-13 13:53:44 +00:00
|
|
|
print(f, "\" ", stylestr(col, outline, (hyperbolic ? current_display->radius : current_display->scrsize) * linewidth/256), "/>");
|
2018-07-19 21:46:58 +00:00
|
|
|
stopstring();
|
2018-12-13 13:53:44 +00:00
|
|
|
println(f);
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
void render(const string& fname, const function<void()>& what) {
|
2018-07-19 21:46:58 +00:00
|
|
|
dynamicval<bool> v2(in, true);
|
2018-12-13 12:33:08 +00:00
|
|
|
dynamicval<bool> v3(vid.usingGL, false);
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 13:53:44 +00:00
|
|
|
#if ISWEB
|
|
|
|
f.s = "";
|
|
|
|
#else
|
|
|
|
f.f = fopen(fname.c_str(), "wt");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
println(f, "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"", coord(vid.xres), "\" height=\"", coord(vid.yres), "\">");
|
2018-12-13 16:57:26 +00:00
|
|
|
if(!shot::transparent)
|
2018-12-21 13:44:55 +00:00
|
|
|
println(f, "<rect width=\"", coord(vid.xres), "\" height=\"", coord(vid.yres), "\" ", stylestr((backcolor << 8) | 0xFF, 0, 0), "/>");
|
2018-08-18 15:44:35 +00:00
|
|
|
what();
|
2018-12-13 13:53:44 +00:00
|
|
|
println(f, "</svg>");
|
|
|
|
|
|
|
|
#if ISWEB
|
|
|
|
EM_ASM_({
|
|
|
|
var x=window.open();
|
|
|
|
x.document.open();
|
|
|
|
x.document.write(Pointer_stringify($0));
|
|
|
|
x.document.close();
|
|
|
|
}, f.s.c_str());
|
|
|
|
#else
|
2019-01-24 13:48:53 +00:00
|
|
|
fclose(f.f); f.f = NULL;
|
2018-12-13 13:53:44 +00:00
|
|
|
#endif
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
2019-02-17 17:43:39 +00:00
|
|
|
|
|
|
|
#if CAP_COMMANDLINE && CAP_SHOT
|
2018-07-19 21:46:58 +00:00
|
|
|
int read_args() {
|
|
|
|
using namespace arg;
|
|
|
|
if(argis("-svgsize")) {
|
2018-12-13 12:33:08 +00:00
|
|
|
shift(); sscanf(argcs(), "%d/%d", &shot::shoty, &svg::divby);
|
|
|
|
if(shot::shotformat == -1) shot::shotformat = 0;
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
else if(argis("-svgfont")) {
|
|
|
|
shift(); svg::font = args();
|
|
|
|
// note: use '-svgfont latex' to produce text output as: \myfont{size}{text}
|
|
|
|
// (this is helpful with Inkscape's PDF+TeX output feature; define \myfont yourself)
|
|
|
|
}
|
|
|
|
else if(argis("-svggamma")) {
|
2018-12-13 12:33:08 +00:00
|
|
|
shift_arg_formula(shot::gamma);
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
else if(argis("-svgshot")) {
|
|
|
|
PHASE(3); shift(); start_game();
|
|
|
|
printf("saving SVG screenshot to %s\n", argcs());
|
2019-01-24 13:48:53 +00:00
|
|
|
shot::make_svg = true;
|
|
|
|
shot::take(argcs());
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
else return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ah = addHook(hooks_args, 0, read_args);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CAP_PNG
|
|
|
|
void IMAGESAVE(SDL_Surface *s, const char *fname) {
|
|
|
|
SDL_Surface *s2 = SDL_PNGFormatAlpha(s);
|
|
|
|
SDL_SavePNG(s2, fname);
|
|
|
|
SDL_FreeSurface(s2);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
#if CAP_SHOT
|
|
|
|
namespace shot {
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
purehookset hooks_hqshot;
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
int shotx = 2000, shoty = 2000;
|
|
|
|
bool make_svg = false;
|
|
|
|
bool transparent = true;
|
|
|
|
ld gamma = 1;
|
|
|
|
int shotformat = -1;
|
|
|
|
string caption;
|
|
|
|
ld fade = 1;
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
void set_shotx() {
|
|
|
|
if(shotformat == -1) return;
|
|
|
|
shotx = shoty;
|
|
|
|
if(shotformat == 1) shotx = shotx * 4/3;
|
|
|
|
if(shotformat == 2) shotx = shotx * 16/9;
|
|
|
|
if(shotformat == 3) {
|
|
|
|
shotx = shotx * 22/16;
|
|
|
|
while(shotx & 15) shotx++;
|
|
|
|
}
|
|
|
|
}
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
#if CAP_SDL
|
|
|
|
int shot_aa = 1;
|
|
|
|
#endif
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
void default_screenshot_content() {
|
|
|
|
#if CAP_RUG
|
|
|
|
if(rug::rugged) {
|
|
|
|
if(rug::in_crystal()) rug::physics();
|
|
|
|
rug::drawRugScene();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
drawfullmap();
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
if(caption != "")
|
|
|
|
displayfr(vid.xres/2, vid.fsize+vid.fsize/4, 3, vid.fsize*2, caption, forecolor, 8);
|
|
|
|
callhooks(hooks_hqshot);
|
|
|
|
drawStats();
|
|
|
|
}
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
#if CAP_PNG
|
|
|
|
void postprocess(string fname, SDL_Surface *sdark, SDL_Surface *sbright) {
|
2018-12-21 13:44:43 +00:00
|
|
|
if(gamma == 1 && shot_aa == 1 && sdark == sbright) {
|
2018-12-13 12:33:08 +00:00
|
|
|
IMAGESAVE(sdark, fname.c_str());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_Surface *sout = SDL_CreateRGBSurface(SDL_SWSURFACE,shotx,shoty,32,0xFF<<16,0xFF<<8,0xFF, (sdark == sbright) ? 0 : (0xFF<<24));
|
|
|
|
for(int y=0; y<shoty; y++)
|
|
|
|
for(int x=0; x<shotx; x++) {
|
|
|
|
int val[2][4];
|
|
|
|
for(int a=0; a<2; a++) for(int b=0; b<3; b++) val[a][b] = 0;
|
|
|
|
for(int ax=0; ax<shot_aa; ax++) for(int ay=0; ay<shot_aa; ay++)
|
|
|
|
for(int b=0; b<2; b++) for(int p=0; p<3; p++)
|
|
|
|
val[b][p] += part(qpixel((b?sbright:sdark), x*shot_aa+ax, y*shot_aa+ay), p);
|
|
|
|
|
|
|
|
int transparent = 0;
|
|
|
|
int maxval = 255 * 3 * shot_aa * shot_aa;
|
|
|
|
|
|
|
|
for(int p=0; p<3; p++) transparent += val[1][p] - val[0][p];
|
|
|
|
|
|
|
|
color_t& pix = qpixel(sout, x, y);
|
|
|
|
pix = 0;
|
|
|
|
part(pix, 3) = 255 - (255 * transparent + (maxval/2)) / maxval;
|
|
|
|
|
|
|
|
if(transparent < maxval) for(int p=0; p<3; p++) {
|
|
|
|
ld v = (val[0][p] * 3. / maxval) / (1 - transparent * 1. / maxval);
|
|
|
|
v = pow(v, gamma) * fade;
|
|
|
|
v *= 255;
|
|
|
|
if(v > 255) v = 255;
|
|
|
|
part(pix, p) = v;
|
|
|
|
}
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
2018-12-13 12:33:08 +00:00
|
|
|
IMAGESAVE(sout, fname.c_str());
|
|
|
|
}
|
|
|
|
#endif
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
void take(string fname, const function<void()>& what) {
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
if(cheater) doOvergenerate();
|
2019-02-21 17:47:48 +00:00
|
|
|
|
|
|
|
#if CAP_SVG
|
2018-12-13 12:33:08 +00:00
|
|
|
int multiplier = make_svg ? svg::divby : shot_aa;
|
2019-02-21 17:47:48 +00:00
|
|
|
#else
|
|
|
|
int multiplier = shot_aa;
|
|
|
|
#endif
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
dynamicval<videopar> v(vid, vid);
|
|
|
|
dynamicval<bool> v2(inHighQual, true);
|
|
|
|
dynamicval<bool> v6(auraNOGL, true);
|
2019-02-06 15:34:42 +00:00
|
|
|
dynamicval<bool> vn(nohud, nohud || hide_hud);
|
2019-05-11 15:20:57 +00:00
|
|
|
dynamicval<int> cgl(vid.cells_generated_limit, 9999999);
|
2019-02-06 15:34:42 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
vid.smart_range_detail *= multiplier;
|
2018-07-19 21:46:58 +00:00
|
|
|
darken = 0;
|
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
set_shotx();
|
|
|
|
vid.xres = shotx * multiplier;
|
|
|
|
vid.yres = shoty * multiplier;
|
|
|
|
calcparam();
|
2019-01-24 13:48:53 +00:00
|
|
|
conformal::configure();
|
2018-12-13 12:33:08 +00:00
|
|
|
|
|
|
|
if(make_svg) {
|
|
|
|
#if CAP_SVG
|
|
|
|
svg::render(fname, what);
|
2018-07-19 21:46:58 +00:00
|
|
|
#endif
|
2018-12-13 12:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
#if CAP_PNG
|
|
|
|
resetbuffer rb;
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
renderbuffer glbuf(vid.xres, vid.yres, vid.usingGL);
|
|
|
|
glbuf.enable();
|
|
|
|
current_display->set_viewport(0);
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 13:53:44 +00:00
|
|
|
dynamicval<color_t> v8(backcolor, transparent ? 0xFF000000 : backcolor);
|
2018-12-13 12:33:08 +00:00
|
|
|
#if CAP_RUG
|
|
|
|
if(rug::rugged && !rug::renderonce) rug::prepareTexture();
|
|
|
|
#endif
|
|
|
|
glbuf.clear(backcolor);
|
|
|
|
what();
|
2018-07-19 21:46:58 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
SDL_Surface *sdark = glbuf.render();
|
|
|
|
|
|
|
|
if(transparent) {
|
|
|
|
renderbuffer glbuf1(vid.xres, vid.yres, vid.usingGL);
|
|
|
|
backcolor = 0xFFFFFFFF;
|
|
|
|
#if CAP_RUG
|
|
|
|
if(rug::rugged && !rug::renderonce) rug::prepareTexture();
|
|
|
|
#endif
|
|
|
|
glbuf1.enable();
|
|
|
|
glbuf1.clear(backcolor);
|
|
|
|
current_display->set_viewport(0);
|
|
|
|
what();
|
|
|
|
|
|
|
|
postprocess(fname, sdark, glbuf1.render());
|
|
|
|
}
|
|
|
|
else postprocess(fname, sdark, sdark);
|
|
|
|
#endif
|
|
|
|
}
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#if CAP_COMMANDLINE
|
|
|
|
int png_read_args() {
|
|
|
|
using namespace arg;
|
|
|
|
if(argis("-pngshot")) {
|
|
|
|
PHASE(3); shift(); start_game();
|
|
|
|
printf("saving PNG screenshot to %s\n", argcs());
|
2018-12-13 12:33:08 +00:00
|
|
|
make_svg = false;
|
|
|
|
shot::take(argcs());
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
else if(argis("-pngsize")) {
|
2018-12-13 12:33:08 +00:00
|
|
|
shift(); shoty = argi(); if(shotformat == -1) shotformat = 0;
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
|
|
|
else if(argis("-pngformat")) {
|
2018-12-13 12:33:08 +00:00
|
|
|
shift(); shotformat = argi();
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|
2019-01-24 13:48:53 +00:00
|
|
|
else if(argis("-shotxy")) {
|
|
|
|
shift(); shotformat = -1; shotx = argi(); shift(); shoty = argi();
|
|
|
|
}
|
2018-12-21 13:45:09 +00:00
|
|
|
else if(argis("-shott")) {
|
|
|
|
shift(); shot::transparent = argi();
|
|
|
|
}
|
2019-06-11 08:20:13 +00:00
|
|
|
else if(argis("-shotaa")) {
|
|
|
|
shift(); shot_aa = argi();
|
|
|
|
}
|
2018-07-19 21:46:58 +00:00
|
|
|
else return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto ah_png = addHook(hooks_args, 0, png_read_args);
|
|
|
|
#endif
|
2018-09-10 15:58:36 +00:00
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
void menu() {
|
|
|
|
cmode = sm::SIDE;
|
|
|
|
gamescreen(0);
|
|
|
|
if(!CAP_SVG) make_svg = false;
|
|
|
|
if(!CAP_PNG) make_svg = true;
|
|
|
|
dialog::init(XLAT("screenshots"), iinf[itPalace].color, 150, 100);
|
|
|
|
dialog::addSelItem(XLAT("format"), make_svg ? "SVG" : "PNG", 'f');
|
|
|
|
dialog::add_action([] { make_svg = !make_svg; });
|
|
|
|
dialog::addSelItem(XLAT("pixels (X)"), its(shotx), 'x');
|
|
|
|
dialog::add_action([] { shotformat = -1; dialog::editNumber(shotx, 500, 8000, 100, 2000, XLAT("pixels (X)"), ""); });
|
|
|
|
dialog::addSelItem(XLAT("pixels (Y)"), its(shoty), 'y');
|
|
|
|
dialog::add_action([] { shotformat = -1; dialog::editNumber(shoty, 500, 8000, 100, 2000, XLAT("pixels (Y)"), ""); });
|
|
|
|
if(make_svg) {
|
2019-02-21 17:47:48 +00:00
|
|
|
#if CAP_SVG
|
2018-12-13 12:33:08 +00:00
|
|
|
using namespace svg;
|
|
|
|
dialog::addSelItem(XLAT("precision"), "1/"+its(divby), 'p');
|
|
|
|
dialog::add_action([] { divby *= 10; if(divby > 1000000) divby = 1; });
|
2019-02-21 17:47:48 +00:00
|
|
|
#endif
|
2018-12-13 12:33:08 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
dialog::addSelItem(XLAT("supersampling"), its(shot_aa), 's');
|
|
|
|
dialog::add_action([] { shot_aa *= 2; if(shot_aa > 16) shot_aa = 1; });
|
|
|
|
}
|
2019-05-03 10:11:40 +00:00
|
|
|
dialog::addBoolItem_action(XLAT("transparent"), transparent, 't');
|
2018-12-13 12:33:08 +00:00
|
|
|
|
|
|
|
dialog::addSelItem(XLAT("gamma"), fts(gamma), 'g');
|
|
|
|
dialog::add_action([] { dialog::editNumber(gamma, 0, 2, .1, .5, XLAT("gamma"), "higher value = darker"); });
|
|
|
|
|
|
|
|
dialog::addSelItem(XLAT("brightness"), fts(fade), 'b');
|
|
|
|
dialog::add_action([] { dialog::editNumber(fade, 0, 2, .1, 1, XLAT("brightness"), "higher value = lighter"); });
|
|
|
|
|
2019-05-03 10:11:40 +00:00
|
|
|
dialog::addBoolItem_action(XLAT("disable the HUD"), hide_hud, 'h');
|
2019-02-06 15:34:42 +00:00
|
|
|
|
2019-05-03 10:11:40 +00:00
|
|
|
dialog::addBoolItem_action_neg(XLAT("hide the player"), mapeditor::drawplayer, 'H');
|
2018-12-13 12:33:08 +00:00
|
|
|
|
2019-03-30 22:59:51 +00:00
|
|
|
dialog::addItem(XLAT("colors & aura"), 'c');
|
|
|
|
dialog::add_action_push(show_color_dialog);
|
2018-12-13 12:33:08 +00:00
|
|
|
|
|
|
|
menuitem_sightrange('r');
|
|
|
|
|
|
|
|
dialog::addBreak(100);
|
|
|
|
|
2018-12-13 16:24:47 +00:00
|
|
|
#if CAP_RUG
|
|
|
|
if(make_svg && rug::rugged)
|
2018-12-14 17:21:52 +00:00
|
|
|
dialog::addInfo("SVG screenshots do not work in this 3D mode", 0xFF0000);
|
2018-12-13 16:24:47 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
#if CAP_TEXTURE
|
|
|
|
if(make_svg && texture::config.tstate == texture::tsActive)
|
2018-12-14 17:21:52 +00:00
|
|
|
dialog::addInfo("SVG screenshots do not work with textures", 0xFF0000);
|
2018-12-13 16:24:47 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
dialog::addBreak(100);
|
|
|
|
|
2018-12-13 12:33:08 +00:00
|
|
|
dialog::addItem(XLAT("take screenshot"), 'z');
|
|
|
|
dialog::add_action([] () {
|
2018-12-13 13:53:44 +00:00
|
|
|
#if ISWEB
|
|
|
|
shot::take("new window");
|
|
|
|
#else
|
2018-12-13 12:33:08 +00:00
|
|
|
static string pngfile = "hqshot.png";
|
|
|
|
static string svgfile = "svgshot.svg";
|
|
|
|
string& file = make_svg ? svgfile : pngfile;
|
|
|
|
dialog::openFileDialog(file, XLAT("screenshot"), make_svg ? ".svg" : ".png", [&file] () {
|
|
|
|
shot::take(file);
|
|
|
|
return true;
|
|
|
|
});
|
2018-12-13 13:53:44 +00:00
|
|
|
#endif
|
2018-12-13 12:33:08 +00:00
|
|
|
});
|
|
|
|
dialog::addBack();
|
|
|
|
dialog::display();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-09-10 15:58:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CAP_ANIMATIONS
|
|
|
|
namespace anims {
|
|
|
|
|
|
|
|
enum eMovementAnimation {
|
2019-07-03 03:01:27 +00:00
|
|
|
maNone, maTranslation, maRotation, maCircle, maParabolic, maTranslationRotation
|
2018-09-10 15:58:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
eMovementAnimation ma;
|
|
|
|
|
|
|
|
ld shift_angle, movement_angle;
|
2019-03-21 02:23:06 +00:00
|
|
|
ld normal_angle = 90;
|
2018-09-10 15:58:36 +00:00
|
|
|
ld period = 10000;
|
|
|
|
int noframes = 30;
|
|
|
|
ld cycle_length = 2 * M_PI;
|
|
|
|
ld parabolic_length = 1;
|
2018-11-06 14:53:50 +00:00
|
|
|
ld skiprope_rotation;
|
2018-09-10 15:58:36 +00:00
|
|
|
|
|
|
|
int lastticks, bak_turncount;
|
|
|
|
|
|
|
|
ld rug_rotation1, rug_rotation2, ballangle_rotation, env_ocean, env_volcano;
|
2019-05-06 23:23:47 +00:00
|
|
|
bool env_shmup;
|
2018-09-10 15:58:36 +00:00
|
|
|
ld rug_angle;
|
|
|
|
|
|
|
|
heptspin rotation_center_h;
|
|
|
|
cellwalker rotation_center_c;
|
|
|
|
transmatrix rotation_center_View;
|
|
|
|
|
|
|
|
color_t circle_display_color = 0x00FF00FF;
|
|
|
|
|
|
|
|
ld circle_radius = acosh(2.), circle_spins = 1;
|
|
|
|
|
|
|
|
void moved() {
|
|
|
|
optimizeview();
|
2018-09-23 21:55:03 +00:00
|
|
|
if(cheater || autocheat) {
|
2019-02-06 15:35:04 +00:00
|
|
|
if(hyperbolic && memory_saving_mode && centerover.at && gmatrix.size() && cwt.at != centerover.at && !quotient) {
|
2018-09-23 21:55:03 +00:00
|
|
|
if(isNeighbor(cwt.at, centerover.at)) {
|
|
|
|
cwt.spin = neighborId(centerover.at, cwt.at);
|
|
|
|
flipplayer = true;
|
|
|
|
}
|
|
|
|
animateMovement(cwt.at, centerover.at, LAYER_SMALL, NODIR);
|
|
|
|
cwt.at = centerover.at;
|
|
|
|
save_memory();
|
|
|
|
return;
|
|
|
|
}
|
2018-09-10 15:58:36 +00:00
|
|
|
setdist(masterless ? centerover.at : viewctr.at->c7, 7 - getDistLimit() - genrange_bonus, NULL);
|
2018-09-23 21:55:03 +00:00
|
|
|
}
|
2018-09-10 15:58:36 +00:00
|
|
|
playermoved = false;
|
|
|
|
}
|
|
|
|
|
2018-11-09 19:41:55 +00:00
|
|
|
struct animated_parameter {
|
|
|
|
ld *value;
|
|
|
|
ld last;
|
|
|
|
string formula;
|
|
|
|
reaction_t reaction;
|
2018-09-10 15:58:36 +00:00
|
|
|
};
|
|
|
|
|
2018-11-09 19:41:55 +00:00
|
|
|
vector<animated_parameter> aps;
|
|
|
|
|
|
|
|
void deanimate(ld &x) {
|
|
|
|
for(int i=0; i<isize(aps); i++)
|
|
|
|
if(aps[i].value == &x)
|
|
|
|
aps.erase(aps.begin() + (i--));
|
|
|
|
}
|
|
|
|
|
|
|
|
void get_parameter_animation(ld &x, string &s) {
|
|
|
|
for(auto &ap: aps)
|
|
|
|
if(ap.value == &x && ap.last == x)
|
|
|
|
s = ap.formula;
|
|
|
|
}
|
|
|
|
|
|
|
|
void animate_parameter(ld &x, string f, const reaction_t& r) {
|
|
|
|
deanimate(x);
|
|
|
|
aps.emplace_back(animated_parameter{&x, x, f, r});
|
|
|
|
}
|
2018-09-10 15:58:36 +00:00
|
|
|
|
2018-11-09 19:41:55 +00:00
|
|
|
int ap_changes;
|
|
|
|
|
|
|
|
void apply_animated_parameters() {
|
|
|
|
ap_changes = 0;
|
|
|
|
for(auto &ap: aps) {
|
|
|
|
if(*ap.value != ap.last) continue;
|
|
|
|
*ap.value = parseld(ap.formula);
|
|
|
|
if(*ap.value != ap.last) {
|
|
|
|
if(ap.reaction) ap.reaction();
|
|
|
|
ap_changes++;
|
|
|
|
ap.last = *ap.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-09-10 15:58:36 +00:00
|
|
|
|
|
|
|
bool needs_highqual;
|
|
|
|
|
2018-10-26 19:03:27 +00:00
|
|
|
bool joukowsky_anim;
|
|
|
|
|
2018-09-23 21:55:03 +00:00
|
|
|
void reflect_view() {
|
|
|
|
if(centerover.at) {
|
|
|
|
transmatrix T = Id;
|
|
|
|
cell *mbase = centerover.at;
|
|
|
|
cell *c = centerover.at;
|
|
|
|
if(shmup::reflect(c, mbase, T))
|
|
|
|
View = inverse(T) * View;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-08 15:28:17 +00:00
|
|
|
|
2018-09-10 15:58:36 +00:00
|
|
|
void apply() {
|
|
|
|
int t = ticks - lastticks;
|
|
|
|
lastticks = ticks;
|
2018-09-23 21:55:03 +00:00
|
|
|
|
2018-09-10 15:58:36 +00:00
|
|
|
switch(ma) {
|
|
|
|
case maTranslation:
|
|
|
|
if(conformal::on) {
|
|
|
|
conformal::phase = (isize(conformal::v) - 1) * ticks * 1. / period;
|
|
|
|
conformal::movetophase();
|
|
|
|
}
|
2018-09-23 21:55:03 +00:00
|
|
|
else if(centerover.at) {
|
|
|
|
reflect_view();
|
|
|
|
if((hyperbolic && !quotient &&
|
|
|
|
(centerover.at->land != cwt.at->land || memory_saving_mode) && among(centerover.at->land, laHaunted, laIvoryTower, laDungeon, laEndorian) && centerover.at->landparam >= 10
|
2018-09-10 17:39:44 +00:00
|
|
|
) ) {
|
2018-09-23 21:55:03 +00:00
|
|
|
if(memory_saving_mode) {
|
|
|
|
activateSafety(laIce);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fullcenter(); View = spin(rand() % 1000) * View;
|
|
|
|
}
|
2018-09-10 17:39:44 +00:00
|
|
|
}
|
2019-03-21 02:23:06 +00:00
|
|
|
View = cspin(0, DIM-1, movement_angle * degree) * ypush(shift_angle * degree) * xpush(cycle_length * t / period) * ypush(-shift_angle * degree) *
|
|
|
|
cspin(0, DIM-1, -movement_angle * degree) * View;
|
2018-09-10 15:58:36 +00:00
|
|
|
moved();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case maRotation:
|
2019-03-21 02:23:06 +00:00
|
|
|
if(DIM == 3) {
|
|
|
|
View = spin(-movement_angle * degree) * View;
|
|
|
|
View = cspin(1, 2, normal_angle * degree) * View;
|
|
|
|
}
|
2018-09-10 15:58:36 +00:00
|
|
|
View = spin(2 * M_PI * t / period) * View;
|
2019-03-21 02:23:06 +00:00
|
|
|
if(DIM == 3) {
|
|
|
|
View = cspin(2, 1, normal_angle * degree) * View;
|
|
|
|
View = spin(movement_angle * degree) * View;
|
|
|
|
}
|
2018-09-10 15:58:36 +00:00
|
|
|
break;
|
2019-07-03 03:01:27 +00:00
|
|
|
|
|
|
|
case maTranslationRotation:
|
|
|
|
View = cspin(0, DIM-1, movement_angle * degree) * ypush(shift_angle * degree) * xpush(cycle_length * t / period) * ypush(-shift_angle * degree) *
|
|
|
|
cspin(0, DIM-1, -movement_angle * degree) * View;
|
|
|
|
moved();
|
|
|
|
View = spin(2 * M_PI * t / period) * View;
|
|
|
|
break;
|
|
|
|
|
2019-02-17 17:28:20 +00:00
|
|
|
#if CAP_BT
|
2018-09-10 15:58:36 +00:00
|
|
|
case maParabolic:
|
2018-09-23 21:55:03 +00:00
|
|
|
reflect_view();
|
2019-03-21 02:23:06 +00:00
|
|
|
View = ypush(-shift_angle * degree) * spin(-movement_angle * degree) * View;
|
|
|
|
if(DIM == 2)
|
|
|
|
View = binary::parabolic(parabolic_length * t / period) * View;
|
|
|
|
else
|
|
|
|
View = binary::parabolic3(parabolic_length * t / period, 0) * View;
|
|
|
|
View = spin(movement_angle * degree) * ypush(shift_angle * degree) * View;
|
2018-09-10 15:58:36 +00:00
|
|
|
moved();
|
|
|
|
break;
|
2019-02-17 17:28:20 +00:00
|
|
|
#endif
|
2018-09-10 15:58:36 +00:00
|
|
|
case maCircle: {
|
|
|
|
if(masterless) centerover = rotation_center_c;
|
|
|
|
else viewctr = rotation_center_h;
|
|
|
|
ld alpha = circle_spins * 2 * M_PI * ticks / period;
|
|
|
|
View = spin(-cos_auto(circle_radius)*alpha) * xpush(circle_radius) * spin(alpha) * rotation_center_View;
|
|
|
|
moved();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(env_ocean) {
|
|
|
|
turncount += env_ocean * ticks * tidalsize / period;
|
|
|
|
calcTidalPhase();
|
|
|
|
for(auto& p: gmatrix) if(p.first->land == laOcean) checkTide(p.first);
|
|
|
|
turncount -= ticks * tidalsize / period;
|
|
|
|
}
|
|
|
|
if(env_volcano) {
|
|
|
|
bak_turncount = turncount;
|
|
|
|
turncount += env_volcano * ticks * 64 / period;
|
|
|
|
for(auto& p: gmatrix) if(p.first->land == laVolcano) checkTide(p.first);
|
|
|
|
}
|
2019-02-17 17:45:42 +00:00
|
|
|
#if CAP_RUG
|
2018-09-10 15:58:36 +00:00
|
|
|
if(rug::rugged) {
|
|
|
|
if(rug_rotation1) {
|
2019-03-21 02:23:06 +00:00
|
|
|
rug::apply_rotation(rotmatrix(rug_angle * degree, 1, 2));
|
2018-09-10 15:58:36 +00:00
|
|
|
rug::apply_rotation(rotmatrix(rug_rotation1 * 2 * M_PI * t / period, 0, 2));
|
2019-03-21 02:23:06 +00:00
|
|
|
rug::apply_rotation(rotmatrix(-rug_angle * degree, 1, 2));
|
2018-09-10 15:58:36 +00:00
|
|
|
}
|
|
|
|
if(rug_rotation2) {
|
|
|
|
rug::apply_rotation(rug::currentrot * rotmatrix(rug_rotation2 * 2 * M_PI * t / period, 0, 1) * inverse(rug::currentrot));
|
|
|
|
}
|
|
|
|
}
|
2019-02-17 17:45:42 +00:00
|
|
|
#endif
|
2018-11-06 14:53:50 +00:00
|
|
|
vid.skiprope += skiprope_rotation * t * 2 * M_PI / period;
|
|
|
|
|
2018-10-23 14:58:19 +00:00
|
|
|
if(ballangle_rotation) {
|
|
|
|
if(conformal::model_has_orientation())
|
|
|
|
conformal::model_orientation += ballangle_rotation * 360 * t / period;
|
|
|
|
else
|
|
|
|
vid.ballangle += ballangle_rotation * 360 * t / period;
|
|
|
|
}
|
2018-10-26 19:03:27 +00:00
|
|
|
if(joukowsky_anim) {
|
|
|
|
ld t = ticks / period;
|
|
|
|
t = t - floor(t);
|
2018-10-28 01:16:03 +00:00
|
|
|
if(pmodel == mdBand) {
|
|
|
|
conformal::model_transition = t * 4 - 1;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
conformal::model_transition = t / 1.1;
|
|
|
|
vid.scale = (1 - conformal::model_transition) / 2.;
|
|
|
|
}
|
2018-10-26 19:03:27 +00:00
|
|
|
}
|
2018-11-09 19:41:55 +00:00
|
|
|
apply_animated_parameters();
|
|
|
|
calcparam();
|
2018-09-10 15:58:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void rollback() {
|
|
|
|
if(env_volcano) {
|
|
|
|
turncount = bak_turncount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-15 14:20:27 +00:00
|
|
|
#if CAP_FILES && CAP_SHOT
|
2018-09-10 17:44:01 +00:00
|
|
|
string animfile = "animation-%04d.png";
|
2018-09-10 15:58:36 +00:00
|
|
|
|
2019-06-11 08:20:21 +00:00
|
|
|
int min_frame = 0, max_frame = 999999;
|
|
|
|
|
2018-09-10 15:58:36 +00:00
|
|
|
bool record_animation() {
|
2018-11-11 15:35:27 +00:00
|
|
|
lastticks = 0;
|
2018-11-18 16:32:13 +00:00
|
|
|
ticks = 0;
|
2018-09-10 15:58:36 +00:00
|
|
|
for(int i=0; i<noframes; i++) {
|
2019-06-11 08:20:21 +00:00
|
|
|
if(i < min_frame || i > max_frame) continue;
|
2019-04-22 12:41:38 +00:00
|
|
|
printf("%d/%d\n", i, noframes);
|
2018-11-18 16:32:13 +00:00
|
|
|
int newticks = i * period / noframes;
|
2019-05-06 23:23:47 +00:00
|
|
|
cmode = (env_shmup ? sm::NORMAL : 0);
|
2018-11-18 16:32:13 +00:00
|
|
|
while(ticks < newticks) shmup::turn(1), ticks++;
|
2019-05-06 23:23:47 +00:00
|
|
|
if(playermoved) centerpc(INF), optimizeview();
|
2019-04-07 01:09:52 +00:00
|
|
|
dynamicval<bool> v2(inHighQual, true);
|
2018-10-28 01:16:22 +00:00
|
|
|
apply();
|
|
|
|
conformal::configure();
|
2018-10-23 14:58:19 +00:00
|
|
|
if(conformal::on) {
|
2019-06-17 06:12:36 +00:00
|
|
|
ld len = (isize(conformal::v)-1) + 2 * conformal::extra_line_steps;
|
|
|
|
conformal::phase = len * i / (noframes-1);
|
2019-06-16 13:26:53 +00:00
|
|
|
if(conformal::lvspeed < 0) conformal::phase = len - conformal::phase;
|
2019-06-17 06:12:36 +00:00
|
|
|
conformal::phase -= conformal::extra_line_steps;
|
2018-10-23 14:58:19 +00:00
|
|
|
conformal::movetophase();
|
|
|
|
}
|
2018-09-10 15:58:36 +00:00
|
|
|
|
|
|
|
char buf[1000];
|
|
|
|
snprintf(buf, 1000, animfile.c_str(), i);
|
2018-12-13 12:33:08 +00:00
|
|
|
shot::take(buf);
|
2018-09-10 20:37:17 +00:00
|
|
|
rollback();
|
2018-09-10 15:58:36 +00:00
|
|
|
}
|
2018-11-11 15:43:43 +00:00
|
|
|
lastticks = ticks = SDL_GetTicks();
|
2018-09-10 15:58:36 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void display_animation() {
|
|
|
|
if(ma == maCircle && (circle_display_color & 0xFF)) {
|
|
|
|
for(int s=0; s<10; s++) {
|
2018-09-10 17:30:51 +00:00
|
|
|
if(s == 0) curvepoint(ggmatrix(rotation_center_c.at) * xpush0(circle_radius - .1));
|
2018-09-10 15:58:36 +00:00
|
|
|
for(int z=0; z<100; z++) curvepoint(ggmatrix(rotation_center_c.at) * xspinpush0((z+s*100) * 2 * M_PI / 1000., circle_radius));
|
|
|
|
queuecurve(circle_display_color, 0, PPR::LINE);
|
|
|
|
}
|
|
|
|
if(sphere) for(int s=0; s<10; s++) {
|
2018-09-10 17:30:51 +00:00
|
|
|
if(s == 0) curvepoint(centralsym * ggmatrix(rotation_center_c.at) * xpush0(circle_radius - .1));
|
2018-09-10 15:58:36 +00:00
|
|
|
for(int z=0; z<100; z++) curvepoint(centralsym * ggmatrix(rotation_center_c.at) * xspinpush0((z+s*100) * 2 * M_PI / 1000., circle_radius));
|
|
|
|
queuecurve(circle_display_color, 0, PPR::LINE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void animator(string caption, ld& param, char key) {
|
|
|
|
dialog::addBoolItem(caption, param, key);
|
|
|
|
if(param) dialog::lastItem().value = fts(param);
|
|
|
|
dialog::add_action([¶m, caption] () {
|
|
|
|
if(param == 0) {
|
|
|
|
param = 1;
|
2018-09-10 17:31:10 +00:00
|
|
|
string s =
|
|
|
|
XLAT(
|
|
|
|
"The value of 1 means that the period of this animation equals the period set in the animation menu. "
|
|
|
|
"Larger values correspond to faster animations.");
|
2018-11-09 19:41:55 +00:00
|
|
|
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::editNumber(param, 0, 10, 1, 1, caption, s);
|
2018-09-10 15:58:36 +00:00
|
|
|
}
|
|
|
|
else param = 0;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-11-09 20:18:58 +00:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2018-09-10 15:58:36 +00:00
|
|
|
ld animation_period;
|
|
|
|
|
|
|
|
void show() {
|
|
|
|
cmode = sm::SIDE; needs_highqual = false;
|
|
|
|
animation_lcm = 1;
|
|
|
|
gamescreen(0);
|
|
|
|
animation_period = 2 * M_PI * animation_lcm / animation_factor;
|
|
|
|
dialog::init(XLAT("animations"), iinf[itPalace].color, 150, 100);
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::addSelItem(XLAT("period"), fts(period)+ " ms", 'p');
|
|
|
|
dialog::add_action([] () { dialog::editNumber(period, 0, 10000, 1000, 200, XLAT("period"),
|
|
|
|
XLAT("This is the period of the whole animation, though in some settings the animation can have a different period or be aperiodic. "
|
|
|
|
"Changing the value will make the whole animation slower or faster."
|
|
|
|
)); });
|
2018-09-10 15:58:36 +00:00
|
|
|
if(animation_lcm > 1) {
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::addSelItem(XLAT("game animation period"), fts(animation_period)+ " ms", 'G');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () {
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::editNumber(animation_period, 0, 10000, 1000, 1000, XLAT("game animation period"),
|
|
|
|
XLAT("Least common multiple of the animation periods of all the game objects on screen, such as rotating items.")
|
|
|
|
);
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::reaction = [] () { animation_factor = 2 * M_PI * animation_lcm / animation_period; };
|
|
|
|
dialog::extra_options = [] () {
|
|
|
|
dialog::addItem("default", 'D');
|
|
|
|
dialog::add_action([] () {
|
|
|
|
animation_factor = 1;
|
|
|
|
popScreen();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
2019-05-03 10:11:40 +00:00
|
|
|
dialog::addBoolItem_choice(XLAT("no movement animation"), ma, maNone, '0');
|
|
|
|
dialog::addBoolItem_choice(XLAT("translation"), ma, maTranslation, '1');
|
|
|
|
dialog::addBoolItem_choice(XLAT("rotation"), ma, maRotation, '2');
|
2018-09-10 15:58:36 +00:00
|
|
|
if(hyperbolic) {
|
2019-05-03 10:11:40 +00:00
|
|
|
dialog::addBoolItem_choice(XLAT("parabolic"), ma, maParabolic, '3');
|
2018-09-10 15:58:36 +00:00
|
|
|
}
|
2018-10-26 19:03:27 +00:00
|
|
|
if(among(pmodel, mdJoukowsky, mdJoukowskyInverted)) {
|
2019-05-03 10:11:40 +00:00
|
|
|
dialog::addBoolItem_action(XLAT("joukowsky_anim"), joukowsky_anim, 'j');
|
2018-10-26 19:03:27 +00:00
|
|
|
}
|
2018-11-06 14:54:55 +00:00
|
|
|
if(among(pmodel, mdJoukowsky, mdJoukowskyInverted)) {
|
|
|
|
animator(XLAT("Möbius transformations"), skiprope_rotation, 'S');
|
|
|
|
}
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::addBoolItem(XLAT("circle"), ma == maCircle, '4');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () { ma = maCircle;
|
|
|
|
rotation_center_h = viewctr;
|
|
|
|
rotation_center_c = centerover;
|
|
|
|
rotation_center_View = View;
|
|
|
|
});
|
2019-07-03 03:01:27 +00:00
|
|
|
dialog::addBoolItem_choice(XLAT("translation")+"+"+XLAT("rotation"), ma, maTranslationRotation, '5');
|
2018-09-10 15:58:36 +00:00
|
|
|
switch(ma) {
|
|
|
|
case maCircle: {
|
2019-06-01 18:20:36 +00:00
|
|
|
animator(XLAT("circle spins"), circle_spins, 'C');
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::addSelItem(XLAT("circle radius"), fts(circle_radius), 'c');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () {
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::editNumber(circle_radius, 0, 10, 0.1, acosh(1.), XLAT("circle radius"), "");
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::extra_options = [] () {
|
|
|
|
if(hyperbolic) {
|
|
|
|
// area = 2pi (cosh(r)-1)
|
2018-11-09 21:18:18 +00:00
|
|
|
dialog::addSelItem(XLAT("double spin"), fts(acosh(2.)), 'A');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () { circle_radius = acosh(2.); });
|
2018-11-09 21:18:18 +00:00
|
|
|
dialog::addSelItem(XLAT("triple spin"), fts(acosh(3.)), 'B');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () { circle_radius = acosh(3.); });
|
|
|
|
}
|
|
|
|
if(sphere) {
|
2018-11-09 21:18:18 +00:00
|
|
|
dialog::addSelItem(XLAT("double spin"), fts(acos(1/2.)), 'A');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () { circle_radius = acos(1/2.); });
|
2018-11-09 21:18:18 +00:00
|
|
|
dialog::addSelItem(XLAT("triple spin"), fts(acos(1/3.)), 'B');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () { circle_radius = acos(1/3.); });
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::addColorItem(XLAT("draw the circle"), circle_display_color, 'd');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () {
|
|
|
|
dialog::openColorDialog(circle_display_color, NULL);
|
|
|
|
});
|
|
|
|
dialog::addBreak(100);
|
2019-06-01 18:20:36 +00:00
|
|
|
break;
|
2018-09-10 15:58:36 +00:00
|
|
|
}
|
|
|
|
case maTranslation:
|
2019-07-03 03:01:27 +00:00
|
|
|
case maTranslationRotation:
|
2018-09-10 15:58:36 +00:00
|
|
|
case maParabolic: {
|
|
|
|
if(ma == maTranslation && conformal::on)
|
|
|
|
dialog::addBreak(300);
|
|
|
|
else if(ma == maTranslation) {
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::addSelItem(XLAT("cycle length"), fts(cycle_length), 'c');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () {
|
|
|
|
dialog::editNumber(cycle_length, 0, 10, 0.1, 2*M_PI, "shift", "");
|
|
|
|
dialog::extra_options = [] () {
|
2018-11-09 21:18:18 +00:00
|
|
|
dialog::addSelItem(XLAT("full circle"), fts(2 * M_PI), 'A');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () { cycle_length = 2 * M_PI; });
|
2018-11-09 21:18:18 +00:00
|
|
|
dialog::addSelItem(XLAT("Zebra period"), fts(2.898149445355172), 'B');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () { cycle_length = 2.898149445355172; });
|
2018-11-09 21:18:18 +00:00
|
|
|
dialog::addSelItem(XLAT("Bolza period"), fts(2 * 1.528571), 'C');
|
2018-09-10 16:06:27 +00:00
|
|
|
dialog::add_action([] () { cycle_length = 2 * 1.528571; });
|
2018-09-10 15:58:36 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::addSelItem(XLAT("cells to go"), fts(parabolic_length), 'c');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () {
|
|
|
|
dialog::editNumber(parabolic_length, 0, 10, 1, 1, "cells to go", "");
|
|
|
|
});
|
|
|
|
}
|
2019-06-01 18:20:36 +00:00
|
|
|
dialog::addSelItem(XLAT("shift"), fts(shift_angle) + "°", 'C');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () {
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::editNumber(shift_angle, 0, 90, 15, 0, XLAT("shift"), "");
|
2018-09-10 15:58:36 +00:00
|
|
|
});
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::addSelItem(XLAT("movement angle"), fts(movement_angle) + "°", 'm');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () {
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::editNumber(movement_angle, 0, 360, 15, 0, XLAT("movement angle"), "");
|
2018-09-10 15:58:36 +00:00
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
2019-03-21 02:23:06 +00:00
|
|
|
case maRotation:
|
|
|
|
if(DIM == 3) {
|
2019-06-01 18:20:36 +00:00
|
|
|
dialog::addSelItem(XLAT("angle to screen normal"), fts(normal_angle) + "°", 'C');
|
2019-03-21 02:23:06 +00:00
|
|
|
dialog::add_action([] () {
|
|
|
|
dialog::editNumber(normal_angle, 0, 360, 15, 0, XLAT("angle to screen normal"), "");
|
|
|
|
});
|
|
|
|
dialog::addSelItem(XLAT("movement angle"), fts(movement_angle) + "°", 'm');
|
|
|
|
dialog::add_action([] () {
|
|
|
|
dialog::editNumber(movement_angle, 0, 360, 15, 0, XLAT("movement angle"), "");
|
|
|
|
});
|
|
|
|
dialog::addBreak(100);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
dialog::addBreak(300);
|
|
|
|
break;
|
2018-09-10 15:58:36 +00:00
|
|
|
default: {
|
|
|
|
dialog::addBreak(300);
|
|
|
|
}
|
|
|
|
}
|
2018-09-10 17:31:10 +00:00
|
|
|
animator(XLATN("Ocean"), env_ocean, 'o');
|
|
|
|
animator(XLATN("Volcanic Wasteland"), env_volcano, 'v');
|
2019-05-06 23:23:47 +00:00
|
|
|
if(shmup::on) dialog::addBoolItem_action(XLAT("shmup action"), env_shmup, 'T');
|
2018-09-10 15:58:36 +00:00
|
|
|
|
|
|
|
#if CAP_RUG
|
|
|
|
if(rug::rugged) {
|
2018-09-10 17:31:10 +00:00
|
|
|
animator(XLAT("screen-relative rotation"), rug_rotation1, 'r');
|
2018-09-10 15:58:36 +00:00
|
|
|
if(rug_rotation1) {
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::addSelItem(XLAT("angle"), fts(rug_angle) + "°", 'a');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () {
|
|
|
|
dialog::editNumber(rug_angle, 0, 360, 15, 0, "Rug angle", "");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else dialog::addBreak(100);
|
2018-09-10 17:31:10 +00:00
|
|
|
animator(XLAT("model-relative rotation"), rug_rotation2, 'r');
|
2018-09-10 16:06:27 +00:00
|
|
|
animator(XLAT("automatic move speed"), rug::ruggo, 'M');
|
|
|
|
dialog::add_action([] () {
|
|
|
|
dialog::editNumber(rug::ruggo, 0, 10, 1, 1, XLAT("automatic move speed"), XLAT("Move automatically without pressing any keys."));
|
|
|
|
if(among(rug::gwhere, gSphere, gElliptic))
|
|
|
|
dialog::extra_options = [] () {
|
|
|
|
dialog::addItem(XLAT("synchronize"), 'S');
|
|
|
|
dialog::add_action([] () { rug::ruggo = 2 * M_PI * 1000 / period; popScreen(); });
|
|
|
|
};
|
|
|
|
});
|
2018-09-10 15:58:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
2018-10-23 14:58:19 +00:00
|
|
|
if(conformal::model_has_orientation())
|
2019-01-02 15:22:34 +00:00
|
|
|
animator(XLAT("model rotation"), ballangle_rotation, 'I');
|
2018-10-23 14:58:19 +00:00
|
|
|
else if(among(pmodel, mdHyperboloid, mdHemisphere, mdBall))
|
2018-12-13 12:33:08 +00:00
|
|
|
animator(XLAT("3D rotation"), ballangle_rotation, '3');
|
2018-09-10 15:58:36 +00:00
|
|
|
|
2018-11-09 20:18:58 +00:00
|
|
|
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;
|
|
|
|
});
|
2018-09-10 15:58:36 +00:00
|
|
|
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::addBoolItem(XLAT("history mode"), (conformal::on || conformal::includeHistory), 'h');
|
2019-03-30 22:59:51 +00:00
|
|
|
dialog::add_action_push(conformal::history_menu);
|
2018-09-10 15:58:36 +00:00
|
|
|
|
2018-12-15 14:20:27 +00:00
|
|
|
#if CAP_FILES && CAP_SHOT
|
2018-12-13 12:33:08 +00:00
|
|
|
dialog::addItem(XLAT("shot settings"), 's');
|
2019-03-30 22:59:51 +00:00
|
|
|
dialog::add_action_push(shot::menu);
|
2018-12-13 12:33:08 +00:00
|
|
|
|
2018-09-10 15:58:36 +00:00
|
|
|
if(needs_highqual)
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::addInfo(XLAT("some parameters will only change in recorded animation"));
|
2018-09-10 15:58:36 +00:00
|
|
|
else
|
|
|
|
dialog::addBreak(100);
|
2018-09-10 17:31:10 +00:00
|
|
|
dialog::addSelItem(XLAT("frames to record"), its(noframes), 'n');
|
|
|
|
dialog::add_action([] () { dialog::editNumber(noframes, 0, 300, 30, 5, XLAT("frames to record"), ""); });
|
|
|
|
dialog::addSelItem(XLAT("record to a file"), animfile, 'R');
|
2018-09-10 15:58:36 +00:00
|
|
|
dialog::add_action([] () {
|
2018-12-13 12:33:08 +00:00
|
|
|
dialog::openFileDialog(animfile, XLAT("record to a file"), shot::make_svg ? ".svg" : ".png", record_animation);
|
2018-09-10 15:58:36 +00:00
|
|
|
});
|
|
|
|
#endif
|
|
|
|
dialog::addBack();
|
|
|
|
dialog::display();
|
|
|
|
}
|
|
|
|
|
2018-12-15 14:17:06 +00:00
|
|
|
#if CAP_COMMANDLINE
|
2018-09-10 15:58:36 +00:00
|
|
|
int readArgs() {
|
|
|
|
using namespace arg;
|
|
|
|
|
|
|
|
if(0) ;
|
2019-02-28 14:06:42 +00:00
|
|
|
#if CAP_ANIMATIONS
|
2018-09-10 15:58:36 +00:00
|
|
|
else if(argis("-animmenu")) {
|
2018-09-10 17:28:46 +00:00
|
|
|
PHASE(3); showstartmenu = false; pushScreen(show);
|
2018-09-10 15:58:36 +00:00
|
|
|
}
|
2018-09-10 17:28:46 +00:00
|
|
|
else if(argis("-animperiod")) {
|
2019-03-30 16:54:43 +00:00
|
|
|
PHASEFROM(2); shift_arg_formula(period);
|
2018-09-10 17:28:46 +00:00
|
|
|
}
|
2019-02-28 14:06:42 +00:00
|
|
|
#if CAP_SHOT
|
2019-05-05 15:38:28 +00:00
|
|
|
else if(argis("-animrecordf")) {
|
|
|
|
PHASEFROM(2); shift(); noframes = argi();
|
|
|
|
shift(); animfile = args();
|
|
|
|
}
|
2019-02-28 14:06:42 +00:00
|
|
|
else if(argis("-animrecord") || argis("-animrec")) {
|
2018-09-10 17:28:46 +00:00
|
|
|
PHASE(3); shift(); noframes = argi();
|
|
|
|
shift(); animfile = args(); record_animation();
|
|
|
|
}
|
2019-06-11 08:20:21 +00:00
|
|
|
else if(argis("-record-only")) {
|
|
|
|
PHASEFROM(2);
|
|
|
|
shift(); min_frame = argi();
|
|
|
|
shift(); max_frame = argi();
|
|
|
|
}
|
2019-02-28 14:06:42 +00:00
|
|
|
#endif
|
2018-09-10 17:28:46 +00:00
|
|
|
else if(argis("-animcircle")) {
|
|
|
|
PHASE(3); start_game();
|
|
|
|
ma = maCircle;
|
|
|
|
rotation_center_h = viewctr;
|
|
|
|
rotation_center_c = cwt.at;
|
|
|
|
rotation_center_View = View;
|
2018-11-09 13:26:31 +00:00
|
|
|
shift_arg_formula(circle_spins);
|
|
|
|
shift_arg_formula(circle_radius);
|
2018-09-10 18:33:06 +00:00
|
|
|
shift(); circle_display_color = arghex();
|
2018-09-10 17:28:46 +00:00
|
|
|
}
|
|
|
|
else if(argis("-animmove")) {
|
|
|
|
ma = maTranslation;
|
2018-11-09 13:26:31 +00:00
|
|
|
shift_arg_formula(cycle_length);
|
|
|
|
shift_arg_formula(shift_angle);
|
|
|
|
shift_arg_formula(movement_angle);
|
2018-09-10 17:28:46 +00:00
|
|
|
}
|
2019-07-03 03:01:27 +00:00
|
|
|
else if(argis("-animmoverot")) {
|
|
|
|
ma = maTranslationRotation;
|
|
|
|
shift_arg_formula(cycle_length);
|
|
|
|
shift_arg_formula(shift_angle);
|
|
|
|
shift_arg_formula(movement_angle);
|
|
|
|
}
|
2018-09-10 17:28:46 +00:00
|
|
|
else if(argis("-animpar")) {
|
|
|
|
ma = maParabolic;
|
2018-11-09 13:26:31 +00:00
|
|
|
shift_arg_formula(parabolic_length);
|
|
|
|
shift_arg_formula(shift_angle);
|
|
|
|
shift_arg_formula(movement_angle);
|
2018-09-10 17:28:46 +00:00
|
|
|
}
|
|
|
|
else if(argis("-animrot")) {
|
|
|
|
ma = maRotation;
|
2019-03-21 18:18:29 +00:00
|
|
|
if(DIM == 3) {
|
|
|
|
shift_arg_formula(movement_angle);
|
|
|
|
shift_arg_formula(normal_angle);
|
|
|
|
}
|
2018-09-10 17:28:46 +00:00
|
|
|
}
|
|
|
|
else if(argis("-animrug")) {
|
2018-11-09 13:26:31 +00:00
|
|
|
shift_arg_formula(rug_rotation1);
|
|
|
|
shift_arg_formula(rug_angle);
|
|
|
|
shift_arg_formula(rug_rotation2);
|
2018-09-10 17:28:46 +00:00
|
|
|
}
|
|
|
|
else if(argis("-animenv")) {
|
2018-11-09 13:26:31 +00:00
|
|
|
shift_arg_formula(env_ocean);
|
|
|
|
shift_arg_formula(env_volcano);
|
2018-09-10 17:28:46 +00:00
|
|
|
}
|
|
|
|
else if(argis("-animball")) {
|
2018-11-09 13:26:31 +00:00
|
|
|
shift_arg_formula(ballangle_rotation);
|
2018-09-10 17:28:46 +00:00
|
|
|
}
|
2018-10-26 19:03:27 +00:00
|
|
|
else if(argis("-animj")) {
|
|
|
|
shift(); joukowsky_anim = true;
|
|
|
|
}
|
2019-02-28 14:06:42 +00:00
|
|
|
#endif
|
2018-09-10 15:58:36 +00:00
|
|
|
else return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
2018-12-15 14:17:06 +00:00
|
|
|
#endif
|
2018-09-10 15:58:36 +00:00
|
|
|
|
2018-12-15 14:17:06 +00:00
|
|
|
auto animhook = addHook(hooks_frame, 100, display_animation)
|
|
|
|
#if CAP_COMMANDLINE
|
|
|
|
+ addHook(hooks_args, 100, readArgs)
|
|
|
|
#endif
|
|
|
|
;
|
2018-09-10 15:58:36 +00:00
|
|
|
|
|
|
|
bool any_animation() {
|
|
|
|
if(conformal::on) return true;
|
|
|
|
if(ma) return true;
|
|
|
|
if(ballangle_rotation || rug_rotation1 || rug_rotation2) return true;
|
2018-11-09 19:41:55 +00:00
|
|
|
if(ap_changes) return true;
|
2018-09-10 15:58:36 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool any_on() {
|
|
|
|
return any_animation() || conformal::includeHistory;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool center_music() {
|
|
|
|
return among(ma, maParabolic, maTranslation);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2018-07-19 21:46:58 +00:00
|
|
|
#endif
|
2018-12-17 10:33:52 +00:00
|
|
|
|
|
|
|
namespace startanims {
|
|
|
|
|
|
|
|
int ticks_start = 0;
|
|
|
|
|
|
|
|
void null_animation() {
|
|
|
|
gamescreen(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void joukowsky() {
|
|
|
|
dynamicval<eModel> dm(pmodel, mdJoukowskyInverted);
|
|
|
|
dynamicval<ld> dt(conformal::model_orientation, ticks / 25.);
|
|
|
|
dynamicval<int> dv(vid.use_smart_range, 2);
|
|
|
|
dynamicval<ld> ds(vid.scale, 1/4.);
|
|
|
|
conformal::configure();
|
|
|
|
dynamicval<color_t> dc(ringcolor, 0);
|
|
|
|
gamescreen(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void bandspin() {
|
|
|
|
dynamicval<eModel> dm(pmodel, mdBand);
|
|
|
|
dynamicval<ld> dt(conformal::model_orientation, ticks / 25.);
|
|
|
|
dynamicval<int> dv(vid.use_smart_range, 2);
|
|
|
|
conformal::configure();
|
|
|
|
gamescreen(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void perspective() {
|
|
|
|
ld x = sin(ticks / 1500.);
|
|
|
|
x += 1;
|
|
|
|
x /= 2;
|
|
|
|
x *= 1.5;
|
|
|
|
x = tan(x);
|
|
|
|
dynamicval<ld> da(vid.alpha, x);
|
|
|
|
dynamicval<ld> ds(vid.scale, (1+x)/2);
|
|
|
|
calcparam();
|
|
|
|
gamescreen(2);
|
|
|
|
}
|
|
|
|
|
2019-02-17 17:45:42 +00:00
|
|
|
#if CAP_RUG
|
2018-12-17 10:33:52 +00:00
|
|
|
void rug() {
|
|
|
|
dynamicval<bool> b(rug::rugged, true);
|
|
|
|
rug::physics();
|
|
|
|
rug::apply_rotation(rotmatrix(ticks / 3000., 1, 2));
|
|
|
|
gamescreen(2);
|
|
|
|
rug::apply_rotation(rotmatrix(-ticks / 3000., 1, 2));
|
|
|
|
}
|
2019-02-17 17:45:42 +00:00
|
|
|
#endif
|
2018-12-17 10:33:52 +00:00
|
|
|
|
|
|
|
void spin_around() {
|
|
|
|
dynamicval<ld> da(vid.alpha, 999);
|
|
|
|
dynamicval<ld> ds(vid.scale, 500);
|
|
|
|
ld alpha = 2 * M_PI * ticks / 10000.;
|
|
|
|
ld circle_radius = acosh(2.);
|
|
|
|
dynamicval<transmatrix> dv(View, spin(-cos_auto(circle_radius)*alpha) * xpush(circle_radius) * spin(alpha) * View);
|
|
|
|
gamescreen(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
reaction_t add_to_frame;
|
|
|
|
|
2019-02-17 17:43:39 +00:00
|
|
|
#if CAP_STARTANIM
|
2018-12-21 13:45:22 +00:00
|
|
|
void draw_ghost(const transmatrix V, int id) {
|
|
|
|
if(id % 13 == 0) {
|
2019-05-26 16:04:02 +00:00
|
|
|
queuepoly(V, cgi.shMiniGhost, 0xFFFF00C0);
|
|
|
|
queuepoly(V, cgi.shMiniEyes, 0xFF);
|
2018-12-21 13:45:22 +00:00
|
|
|
}
|
|
|
|
else {
|
2019-05-26 16:04:02 +00:00
|
|
|
queuepoly(V, cgi.shMiniGhost, 0xFFFFFFC0);
|
|
|
|
queuepoly(V, cgi.shMiniEyes, 0xFF);
|
2018-12-21 13:45:22 +00:00
|
|
|
}
|
2018-12-17 10:33:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void row_of_ghosts() {
|
|
|
|
dynamicval<reaction_t> r(add_to_frame, [] {
|
2018-12-21 13:45:22 +00:00
|
|
|
int t = ticks/400;
|
|
|
|
ld mod = (ticks-t*400)/400.;
|
|
|
|
for(int x=-25; x<=25; x++)
|
|
|
|
for(int y=-25; y<=25; y++) {
|
|
|
|
ld ay = (y + mod)/5.;
|
|
|
|
draw_ghost(xpush(x/5.) * spin(M_PI/2) * xpush(ay), int(y-t));
|
2018-12-17 10:33:52 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
dynamicval<bool> rd(mapeditor::drawplayer, false);
|
|
|
|
gamescreen(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void army_of_ghosts() {
|
|
|
|
dynamicval<bool> rd(mapeditor::drawplayer, false);
|
|
|
|
dynamicval<reaction_t> r(add_to_frame, [] {
|
2018-12-21 13:45:22 +00:00
|
|
|
int tt = ticks - ticks_start + 1200;
|
|
|
|
int t = tt/400;
|
|
|
|
ld mod = (tt-t*400)/400.;
|
|
|
|
for(int x=-12; x<=12; x++) {
|
|
|
|
ld ax = x/4.;
|
|
|
|
transmatrix T = spin(-M_PI/2) * xpush(ax) * spin(M_PI/2);
|
|
|
|
for(int y=0;; y++) {
|
|
|
|
ld ay = (mod - y)/4.;
|
|
|
|
transmatrix U = spin(M_PI/2) * xpush(ay / cosh(ax)) * T;
|
|
|
|
if(!in_smart_range(U)) break;
|
|
|
|
draw_ghost(U, (-y - t));
|
|
|
|
if(y) {
|
|
|
|
ay = (mod + y)/4.;
|
|
|
|
transmatrix U = spin(M_PI/2) * xpush(ay / cosh(ax)) * T;
|
|
|
|
draw_ghost(U, (y - t));
|
|
|
|
}
|
2018-12-17 10:33:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
gamescreen(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ghost_spiral() {
|
|
|
|
dynamicval<reaction_t> r(add_to_frame, [] {
|
|
|
|
ld t = (ticks - ticks_start - 2000) / 150000.;
|
|
|
|
for(ld i=3; i<=40; i++) {
|
2018-12-21 13:45:22 +00:00
|
|
|
draw_ghost(spin(t * i * 2 * M_PI) * xpush(asinh(15. / i)) * spin(M_PI/2), 1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
gamescreen(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fib_ghosts() {
|
|
|
|
dynamicval<bool> rd(mapeditor::drawplayer, false);
|
|
|
|
dynamicval<reaction_t> r(add_to_frame, [] {
|
|
|
|
ld phase = (ticks - ticks_start - 2000) / 1000.;
|
|
|
|
for(int i=0; i<=500; i++) {
|
|
|
|
ld step = M_PI * (3 - sqrt(5));
|
|
|
|
ld density = 0.01;
|
|
|
|
ld area = 1 + (i+.5) * density;
|
|
|
|
ld r = acosh(area);
|
|
|
|
ld length = sinh(r);
|
|
|
|
transmatrix T = spin(i * step + phase / length) * xpush(r) * spin(M_PI/2);
|
|
|
|
draw_ghost(T, i);
|
2018-12-17 10:33:52 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
gamescreen(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// more start animations:
|
|
|
|
// - fly a ghost around center, in Gans model
|
|
|
|
// - triangle edges?
|
|
|
|
|
|
|
|
reaction_t current = null_animation;
|
|
|
|
|
|
|
|
void pick() {
|
2019-07-03 05:51:48 +00:00
|
|
|
if(((gold() > 0 || tkills() > 0) && canmove) || geometry != gNormal || ISWEB || ISMOBILE || vid.always3 || pmodel || rug::rugged || vid.wallmode < 2 || vid.monmode < 2 || glhr::noshaders || !vid.usingGL) {
|
2018-12-17 10:33:52 +00:00
|
|
|
current = null_animation;
|
|
|
|
return;
|
|
|
|
}
|
2018-12-21 13:45:22 +00:00
|
|
|
vector<reaction_t> known = { null_animation, perspective, joukowsky, bandspin, rug, spin_around, row_of_ghosts, ghost_spiral, army_of_ghosts, fib_ghosts };
|
|
|
|
int id = rand() % 10;
|
2018-12-17 10:33:52 +00:00
|
|
|
current = known[id];
|
|
|
|
ticks_start = ticks;
|
|
|
|
if(id == 4) rug::init(), rug::rugged = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto sanimhook = addHook(hooks_frame, 100, []() { if(add_to_frame) add_to_frame(); });
|
2019-02-17 17:43:39 +00:00
|
|
|
#endif
|
2018-12-17 10:33:52 +00:00
|
|
|
|
|
|
|
}
|
2018-07-19 21:46:58 +00:00
|
|
|
}
|