2017-09-17 12:15:24 +00:00
|
|
|
#define VER "10.0o"
|
|
|
|
#define VERNUM 10015
|
|
|
|
#define VERNUM_HEX 0xA00F
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
#define GEN_M 0
|
|
|
|
#define GEN_F 1
|
|
|
|
#define GEN_N 2
|
|
|
|
#define GEN_O 3
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
// OS settings
|
|
|
|
|
|
|
|
#ifndef ISMAC
|
|
|
|
#define ISMAC 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ISLINUX
|
|
|
|
#define ISLINUX 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ISWINDOWS
|
|
|
|
#define ISWINDOWS 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ISPANDORA
|
|
|
|
#define ISPANDORA 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ISIOS
|
|
|
|
#define ISIOS 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ISANDROID
|
|
|
|
#define ISANDROID 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ISWEB
|
|
|
|
#define ISWEB 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ISFAKEMOBILE
|
|
|
|
#define ISFAKEMOBILE 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ISMOBILE (ISIOS || ISANDROID || ISFAKEMOBILE)
|
|
|
|
#define ISMOBWEB (ISMOBILE || ISWEB)
|
|
|
|
|
|
|
|
#ifndef ISMINI
|
|
|
|
#define ISMINI 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_XGD
|
|
|
|
#define CAP_XGD (ISANDROID || ISFAKEMOBILE)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CAP_FRAMELIMIT (!ISMOBWEB)
|
|
|
|
|
|
|
|
#if ISMOBILE==1
|
2017-05-27 19:40:40 +00:00
|
|
|
#define EXTERNALFONT
|
2017-03-23 10:53:57 +00:00
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#ifndef CAP_INV
|
|
|
|
#define CAP_INV 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_ANDROIDSHARE
|
|
|
|
#define CAP_ANDROIDSHARE (ISANDROID)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_SDL
|
|
|
|
#define CAP_SDL (!ISMOBILE)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_SDLGFX
|
|
|
|
#define CAP_SDLGFX (CAP_SDL && !ISWEB)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_GL
|
|
|
|
#define CAP_GL (ISMOBILE || CAP_SDL)
|
2017-03-23 10:53:57 +00:00
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#ifndef CAP_AUDIO
|
|
|
|
#define CAP_AUDIO ((ISMOBILE || CAP_SDL) && !ISWEB && !ISMINI)
|
2017-03-23 10:53:57 +00:00
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#define CAP_GLORNOT (CAP_GL && !ISWEB && !ISIOS)
|
|
|
|
|
|
|
|
#ifndef CAP_CERTIFY
|
|
|
|
#define CAP_CERTIFY 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_RUG
|
|
|
|
#define CAP_RUG (!ISMOBWEB && !ISMINI && CAP_SDL && CAP_GL)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_EDIT
|
2017-08-06 12:50:16 +00:00
|
|
|
#define CAP_EDIT (!ISWEB && !ISMINI)
|
2017-03-23 10:53:57 +00:00
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#ifndef CAP_MODEL
|
|
|
|
#define CAP_MODEL (!ISMOBWEB && !ISMINI && CAP_SDLGFX)
|
2017-03-23 10:53:57 +00:00
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#ifndef CAP_SAVE
|
|
|
|
#define CAP_SAVE (!ISWEB && !ISMINI)
|
2017-05-27 19:40:40 +00:00
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#ifndef CAP_CONFIG
|
|
|
|
#define CAP_CONFIG (!ISWEB && !ISMINI)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_TRANS
|
|
|
|
#define CAP_TRANS (!ISWEB && !ISMINI)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_TOUR
|
|
|
|
#define CAP_TOUR (!ISWEB && !ISMINI)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_ROGUEVIZ
|
|
|
|
#define CAP_ROGUEVIZ 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_PROFILING
|
|
|
|
#define CAP_PROFILING 0
|
2017-07-04 13:38:33 +00:00
|
|
|
#endif
|
2017-05-27 19:40:40 +00:00
|
|
|
|
|
|
|
#define PSEUDOKEY_WHEELDOWN 2501
|
|
|
|
#define PSEUDOKEY_WHEELUP 2502
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#ifndef CAP_PNG
|
|
|
|
#define CAP_PNG (!ISMOBWEB && !ISMAC && CAP_SDLGFX)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_COMMANDLINE
|
|
|
|
#define CAP_COMMANDLINE (!ISMOBILE)
|
2017-05-27 19:40:40 +00:00
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#define CAP_SDLAUDIO (CAP_SDL && CAP_AUDIO)
|
|
|
|
|
|
|
|
#ifndef CAP_SVG
|
|
|
|
#define CAP_SVG (!ISMOBILE)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_SDLJOY
|
|
|
|
#define CAP_SDLJOY (CAP_SDL && !ISWEB)
|
2017-05-27 19:40:40 +00:00
|
|
|
#endif
|
|
|
|
|
2017-08-13 18:49:38 +00:00
|
|
|
#ifndef CAP_SDLTTF
|
2017-07-22 23:33:27 +00:00
|
|
|
#define CAP_SDLTTF (CAP_SDL && !ISMOBILE && !ISWEB)
|
2017-08-13 18:49:38 +00:00
|
|
|
#endif
|
2017-07-04 13:38:33 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#define CAP_GLFONT (CAP_GL && !ISMOBILE)
|
|
|
|
|
|
|
|
#ifndef CAP_TABFONT
|
|
|
|
#define CAP_TABFONT (ISWEB)
|
2017-05-27 19:40:40 +00:00
|
|
|
#endif
|
2017-07-22 23:33:27 +00:00
|
|
|
|
2017-08-13 18:49:38 +00:00
|
|
|
#ifndef CAP_CREATEFONT
|
|
|
|
#define CAP_CREATEFONT 0
|
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#ifndef CAP_FIXEDSIZE
|
2017-08-13 18:49:38 +00:00
|
|
|
#define CAP_FIXEDSIZE (CAP_CREATEFONT || CAP_TABFONT ? 36 : 0)
|
2017-05-27 19:40:40 +00:00
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#ifndef CAP_SHMUP
|
|
|
|
#define CAP_SHMUP 1
|
2017-05-27 19:40:40 +00:00
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-08-13 18:49:38 +00:00
|
|
|
#ifdef ISSTEAM
|
|
|
|
#define CAP_ACHIEVE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CAP_ACHIEVE
|
|
|
|
#define CAP_ACHIEVE 0
|
|
|
|
#endif
|
|
|
|
|
2017-08-06 14:17:13 +00:00
|
|
|
#ifndef CAP_SHMUP_GOOD
|
2017-08-06 14:57:05 +00:00
|
|
|
#define CAP_SHMUP_GOOD (!ISMOBWEB)
|
2017-08-06 14:17:13 +00:00
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if ISMOBILE
|
2017-03-23 10:53:57 +00:00
|
|
|
#define EXTRALICENSE "\n\nHyperRogue soundtrack by Shawn Parrotte (http://www.shawnparrotte.com), under the Creative Commons BY-SA 3.0 license, http://creativecommons.org/licenses/by-sa/3.0/"
|
|
|
|
#undef XEXTRALICENSE
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
int fontscale = 100;
|
|
|
|
bool buttonclicked;
|
|
|
|
void gdpush(int t);
|
|
|
|
#endif
|
|
|
|
|
2017-07-04 13:38:33 +00:00
|
|
|
#ifndef HYPERPATH
|
|
|
|
#define HYPERPATH ""
|
|
|
|
#endif
|
|
|
|
|
2017-05-27 19:40:40 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_SDL
|
2017-05-27 19:40:40 +00:00
|
|
|
#include <SDL/SDL.h>
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if !ISMAC
|
2017-05-27 19:40:40 +00:00
|
|
|
#undef main
|
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_SDLAUDIO
|
2017-05-27 19:40:40 +00:00
|
|
|
#include <SDL/SDL_mixer.h>
|
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_SDLTTF
|
2017-05-27 19:40:40 +00:00
|
|
|
#include <SDL/SDL_ttf.h>
|
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_SDLGFX
|
2017-05-27 19:40:40 +00:00
|
|
|
#include <SDL/SDL_gfxPrimitives.h>
|
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#elif !ISFAKEMOBILE
|
2017-03-23 10:53:57 +00:00
|
|
|
#define SDLK_F1 (123001)
|
|
|
|
#define SDLK_F2 (123002)
|
|
|
|
#define SDLK_F3 (123003)
|
|
|
|
#define SDLK_F4 (123004)
|
|
|
|
#define SDLK_F5 (123005)
|
|
|
|
#define SDLK_F6 (123006)
|
|
|
|
#define SDLK_F7 (123007)
|
2017-05-27 19:40:40 +00:00
|
|
|
#define SDLK_F8 (123008)
|
|
|
|
#define SDLK_F9 (123009)
|
2017-03-23 10:53:57 +00:00
|
|
|
#define SDLK_F10 (123010)
|
|
|
|
#define SDLK_ESCAPE (123099)
|
|
|
|
#define SDLK_F12 (123012)
|
|
|
|
#define SDLK_HOME (123013)
|
|
|
|
#define SDLK_LEFT (123014)
|
|
|
|
#define SDLK_RIGHT (123015)
|
|
|
|
#define MIX_MAX_VOLUME 128
|
|
|
|
#define SDLK_UP (123021)
|
|
|
|
#define SDLK_DOWN (123022)
|
|
|
|
#define SDLK_PAGEUP (123023)
|
|
|
|
#define SDLK_PAGEDOWN (123024)
|
|
|
|
#define SDLK_RETURN (123025)
|
|
|
|
#define SDLK_KP1 (123031)
|
|
|
|
#define SDLK_KP2 (123032)
|
|
|
|
#define SDLK_KP3 (123033)
|
|
|
|
#define SDLK_KP4 (123034)
|
|
|
|
#define SDLK_KP5 (123035)
|
|
|
|
#define SDLK_KP6 (123036)
|
|
|
|
#define SDLK_KP7 (123037)
|
|
|
|
#define SDLK_KP8 (123038)
|
|
|
|
#define SDLK_KP9 (123039)
|
|
|
|
#define SDLK_KP_PERIOD (123051)
|
2017-05-27 19:40:40 +00:00
|
|
|
#define SDLK_KP_MINUS (123053)
|
2017-03-23 10:53:57 +00:00
|
|
|
#define SDLK_DELETE (123052)
|
|
|
|
#define SDLK_DELETE (123052)
|
2017-05-27 19:40:40 +00:00
|
|
|
#define SDLK_KP_ENTER (123054)
|
|
|
|
#define SDLK_BACKSPACE (123055)
|
|
|
|
typedef int SDL_Event;
|
2017-03-23 10:53:57 +00:00
|
|
|
#endif
|
|
|
|
|
2017-08-13 18:49:38 +00:00
|
|
|
#if ISWEB
|
|
|
|
inline Uint8 *SDL_GetKeyState(void *v) { static Uint8 tab[1024]; return tab; }
|
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#ifndef CAP_GLEW
|
|
|
|
#define CAP_GLEW (CAP_GL && !ISMOBILE && !ISMAC && !ISLINUX)
|
2017-07-04 13:38:33 +00:00
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_GLEW
|
2017-05-27 19:40:40 +00:00
|
|
|
#include <GL/glew.h>
|
|
|
|
#else
|
|
|
|
#define GL_GLEXT_PROTOTYPES 1
|
2017-07-22 23:33:27 +00:00
|
|
|
#if ISMAC
|
|
|
|
#include <OpenGL/gl.h>
|
|
|
|
#include <OpenGL/glu.h>
|
|
|
|
#include <OpenGL/glext.h>
|
|
|
|
#elif ISIOS
|
|
|
|
// already included
|
|
|
|
#elif ISANDROID
|
|
|
|
#include <GLES/gl.h>
|
|
|
|
#include <GLES/glext.h>
|
|
|
|
#include <GLES2/gl2.h>
|
|
|
|
#else
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glu.h>
|
|
|
|
#include <GL/glext.h>
|
2017-05-27 19:40:40 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-05-29 09:22:11 +00:00
|
|
|
#include <functional>
|
2017-06-09 01:41:33 +00:00
|
|
|
#include <memory>
|
2017-03-23 10:53:57 +00:00
|
|
|
#include <cmath>
|
|
|
|
#include <time.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2017-05-27 19:40:40 +00:00
|
|
|
#include <string.h>
|
2017-03-23 10:53:57 +00:00
|
|
|
#include <string>
|
|
|
|
#include <map>
|
2017-05-27 19:40:40 +00:00
|
|
|
#include <queue>
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-06-09 01:41:33 +00:00
|
|
|
#include <array>
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
#ifdef USE_UNORDERED_MAP
|
|
|
|
#include <unordered_map>
|
|
|
|
#else
|
|
|
|
#define unordered_map map
|
|
|
|
#endif
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
string s0;
|
|
|
|
void addMessage(string s, char spamtype = 0);
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if ISANDROID
|
2017-03-23 10:53:57 +00:00
|
|
|
FILE *debfile;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
FILE *debugfile;
|
|
|
|
int debugflags;
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_COMMANDLINE
|
2017-03-23 10:53:57 +00:00
|
|
|
const char *scorefile = "hyperrogue.log";
|
|
|
|
const char *conffile = "hyperrogue.ini";
|
|
|
|
string levelfile = "hyperrogue.lev";
|
|
|
|
string picfile = "hyperrogue.pic";
|
|
|
|
const char *musicfile = "";
|
|
|
|
const char *loadlevel = NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define S7 (sphere?5:7)
|
|
|
|
#define S42 (S7*6)
|
|
|
|
#define S14 (S7*2)
|
|
|
|
#define S21 (S7*3)
|
|
|
|
#define S28 (S7*4)
|
|
|
|
#define S84 (S7*12)
|
|
|
|
|
|
|
|
#include "util.cpp"
|
|
|
|
#include "hyperpoint.cpp"
|
|
|
|
#include "patterns.cpp"
|
|
|
|
#include "classes.cpp"
|
|
|
|
#include "fieldpattern.cpp"
|
|
|
|
#include "heptagon.cpp"
|
|
|
|
#include "language.cpp"
|
|
|
|
#include "hyper.h"
|
|
|
|
#include "cell.cpp"
|
|
|
|
#include "flags.cpp"
|
|
|
|
#include "yendor.cpp"
|
|
|
|
#include "complex.cpp"
|
|
|
|
#include "game.cpp"
|
|
|
|
#include "landgen.cpp"
|
|
|
|
#include "orbs.cpp"
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_INV
|
2017-07-16 21:00:55 +00:00
|
|
|
#include "inventory.cpp"
|
2017-07-12 18:44:13 +00:00
|
|
|
#else
|
|
|
|
bool inv::on;
|
2017-07-04 13:38:33 +00:00
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
#include "system.cpp"
|
2017-08-06 12:50:16 +00:00
|
|
|
#include "debug.cpp"
|
2017-03-23 10:53:57 +00:00
|
|
|
#include "geometry.cpp"
|
|
|
|
#include "polygons.cpp"
|
|
|
|
#include "mapeditor.cpp"
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_MODEL
|
2017-03-23 10:53:57 +00:00
|
|
|
#include "netgen.cpp"
|
|
|
|
#endif
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_TABFONT || CAP_CREATEFONT
|
|
|
|
#include "nofont.cpp"
|
2017-07-04 13:38:33 +00:00
|
|
|
#endif
|
2017-07-10 18:47:38 +00:00
|
|
|
#include "basegraph.cpp"
|
|
|
|
#include "help.cpp"
|
|
|
|
#include "config.cpp"
|
|
|
|
#include "scores.cpp"
|
|
|
|
#include "menus.cpp"
|
2017-07-12 16:03:53 +00:00
|
|
|
#include "quit.cpp"
|
2017-07-10 18:47:38 +00:00
|
|
|
#include "shmup.cpp"
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_ROGUEVIZ
|
2017-07-10 18:47:38 +00:00
|
|
|
#include "rogueviz.cpp"
|
|
|
|
#endif
|
|
|
|
#include "conformal.cpp"
|
|
|
|
#include "rug.cpp"
|
|
|
|
#include "control.cpp"
|
|
|
|
#include "hud.cpp"
|
|
|
|
#include "hypgraph.cpp"
|
2017-03-23 10:53:57 +00:00
|
|
|
#include "graph.cpp"
|
|
|
|
#include "sound.cpp"
|
|
|
|
#include "achievement.cpp"
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_TOUR
|
2017-04-08 15:18:29 +00:00
|
|
|
#include "tour.cpp"
|
|
|
|
#endif
|
2017-07-22 23:33:27 +00:00
|
|
|
#if ISMOBILE==0
|
2017-03-23 10:53:57 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bool fixseed = false;
|
2017-07-16 21:00:55 +00:00
|
|
|
int startseed = 0;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
void initAll() {
|
2017-08-06 12:50:16 +00:00
|
|
|
showstartmenu = true;
|
2017-03-23 10:53:57 +00:00
|
|
|
ca::init();
|
|
|
|
arg::read(1);
|
|
|
|
srand(time(NULL));
|
2017-07-16 21:00:55 +00:00
|
|
|
shrand(fixseed ? startseed : time(NULL));
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
achievement_init(); // not in ANDROID
|
|
|
|
|
|
|
|
eLand f = firstland;
|
|
|
|
|
|
|
|
// initlanguage();
|
|
|
|
initgraph();
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_SAVE
|
2017-03-23 10:53:57 +00:00
|
|
|
loadsave();
|
|
|
|
#endif
|
|
|
|
resetGeometry();
|
|
|
|
initcells();
|
|
|
|
|
|
|
|
shmup::safety = safety;
|
|
|
|
initgame();
|
|
|
|
restartGraph();
|
|
|
|
|
|
|
|
if(!shmup::on) {
|
|
|
|
restoreGolems(items[itOrbLife], moGolem); items[itOrbLife] = 0;
|
|
|
|
restoreGolems(items[itOrbFriend], moTameBomberbird); items[itOrbFriend] = 0;
|
|
|
|
restoreGolems(kills[moPrincessMoved], moPrincess, princess::saveHP); kills[moPrincessMoved] = 0;
|
|
|
|
restoreGolems(kills[moPrincessArmedMoved], moPrincessArmed, princess::saveArmedHP); kills[moPrincessArmedMoved] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
firstland = f;
|
|
|
|
}
|
|
|
|
|
|
|
|
void finishAll() {
|
|
|
|
achievement_final(!items[itOrbSafety]);
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_SAVE
|
2017-03-23 10:53:57 +00:00
|
|
|
saveStats();
|
|
|
|
#endif
|
|
|
|
offscreen.clear();
|
|
|
|
clearMemory();
|
2017-07-22 23:33:27 +00:00
|
|
|
#if ISMOBILE==0
|
2017-03-23 10:53:57 +00:00
|
|
|
cleargraph();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
achievement_close();
|
|
|
|
}
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if ISANDROID
|
2017-03-23 10:53:57 +00:00
|
|
|
string buildScoreDescription() {
|
|
|
|
string s;
|
|
|
|
time_t timer;
|
|
|
|
timer = time(NULL);
|
|
|
|
char buf[128]; strftime(buf, 128, "%c", localtime(&timer));
|
|
|
|
char buf2[128];
|
|
|
|
|
|
|
|
s += XLAT("HyperRogue for Android");
|
2017-07-22 23:33:27 +00:00
|
|
|
s += " ( " VER "), http://www.roguetemple.com/z/hyper/\n";
|
2017-03-23 10:53:57 +00:00
|
|
|
s += XLAT("Date: %1 time: %2 s ", buf, its(savetime + time(NULL) - timerstart));
|
|
|
|
s += XLAT("distance: %1\n", its(celldist(cwt.c)));
|
|
|
|
// s += buf2;
|
|
|
|
if(cheater) s += XLAT("Cheats: ") + its(cheater) + "\n";
|
|
|
|
s += XLAT("Score: ") + its(gold());
|
|
|
|
|
|
|
|
for(int i=0; i<ittypes; i++) if(items[i]) {
|
|
|
|
string t = XLATN(iinf[i].name);
|
|
|
|
sprintf(buf2, " %s (%d)", t.c_str(), items[i]);
|
|
|
|
s += buf2;
|
|
|
|
}
|
|
|
|
s += "\n";
|
|
|
|
s += XLAT("Kills: ") + its(tkills());
|
|
|
|
for(int i=1; i<motypes; i++) if(kills[i]) {
|
|
|
|
string t = XLATN(minf[i].name);
|
|
|
|
sprintf(buf2, " %s (%d)", t.c_str(), kills[i]);
|
|
|
|
s += buf2;
|
|
|
|
}
|
|
|
|
s += "\n";
|
|
|
|
|
|
|
|
for(int i=0; i<gamelog.size(); i++) if(gamelog[i].msg != "") s += gamelog[i].msg + "\n";
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if ISMOBILE==1
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
bool lclicked = false, clicked = false;
|
|
|
|
string lmouseovers;
|
|
|
|
bool inmenu = false;
|
|
|
|
|
|
|
|
bool longclick;
|
|
|
|
|
|
|
|
void handleScoreClick();
|
|
|
|
void openURL();
|
|
|
|
void displayTexts();
|
|
|
|
void controlMusic(int ticks);
|
|
|
|
|
|
|
|
void showHelp(MOBPAR_FORMAL, string nhelp) {
|
2017-07-22 23:33:27 +00:00
|
|
|
gotoHelp(nhelp);
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool useRangedOrb;
|
|
|
|
|
|
|
|
void handleclick(MOBPAR_FORMAL) {
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
if(!shmup::on && andmode == 0 && size(screens) == 1 && canmove && !useRangedOrb && vid.mobilecompasssize > 0) {
|
2017-03-23 10:53:57 +00:00
|
|
|
using namespace shmupballs;
|
|
|
|
int dx = mousex - xmove;
|
|
|
|
int dy = mousey - yb;
|
|
|
|
int h = hypot(dx, dy);
|
|
|
|
if(h < rad) {
|
|
|
|
if(h < rad*SKIPFAC) movepcto(MD_WAIT);
|
|
|
|
else {
|
2017-07-10 18:47:38 +00:00
|
|
|
double d = vid.revcontrol ? -1 : 1;
|
2017-03-23 10:53:57 +00:00
|
|
|
mouseh = hpxy(dx * d / rad, dy * d / rad);
|
|
|
|
mousemovement();
|
|
|
|
}
|
|
|
|
getcstat = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-09 01:41:33 +00:00
|
|
|
if(buttonclicked || mouseout()) {
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
if(andmode == 0 && getcstat == 'g' && !shmup::on && size(screens) == 1) {
|
2017-03-23 10:53:57 +00:00
|
|
|
movepcto(MD_DROP);
|
|
|
|
getcstat = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(getcstat != SDLK_F1) {
|
|
|
|
int px = mousex < vid.xcenter ? 0 : 1;
|
|
|
|
int py = mousey < vid.ycenter ? 0 : 1;
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
if(size(screens) == 1) {
|
2017-03-23 10:53:57 +00:00
|
|
|
if(px == 0 && py == 1) {
|
|
|
|
if(andmode == 0 && shmup::on) ;
|
|
|
|
else andmode = 10;
|
|
|
|
}
|
|
|
|
if(px == 1 && py == 1) {
|
|
|
|
if(andmode == 0 && shmup::on) ; // just fire, do not change modes
|
|
|
|
else {
|
|
|
|
if(andmode == 1) {
|
|
|
|
centerpc(INF);
|
|
|
|
View = Id;
|
|
|
|
viewctr.h = cwt.c->master;
|
|
|
|
}
|
|
|
|
andmode = 11;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(px == 0 && py == 0) andmode = 22;
|
|
|
|
if(px == 1 && py == 0) andmode = 13;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
if(andmode == 0 && help != "@") {
|
|
|
|
addMessage(mouseovers);
|
|
|
|
showHelp(MOBPAR_ACTUAL, help);
|
|
|
|
andmode = 10;
|
|
|
|
getcstat = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
if(andmode == 0 && size(screens) == 1 && !mouseout()) {
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
bool forcetarget = longclick;
|
|
|
|
|
|
|
|
if(mouseover && targetclick && targetRangedOrb(mouseover, forcetarget ? roMouseForce : roMouse)) {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
else if(!forcetarget) movepcto(mousedest);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(andmode == 10) {
|
|
|
|
if(!playerfound) {
|
|
|
|
centerpc(INF);
|
|
|
|
View = Id;
|
|
|
|
viewctr.h = cwt.c->master;
|
|
|
|
}
|
|
|
|
playermoved = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(andmode >= 10) andmode -= 10;
|
|
|
|
|
2017-08-06 12:50:16 +00:00
|
|
|
if(andmode == 3) {
|
|
|
|
if(tour::on)
|
|
|
|
showMissionScreen();
|
|
|
|
else
|
|
|
|
pushScreen(showMainMenu);
|
|
|
|
andmode = 0;
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int touchedAt;
|
|
|
|
|
|
|
|
int getticks();
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_ANDROIDSHARE
|
2017-03-31 19:41:09 +00:00
|
|
|
void shareScore(MOBPAR_FORMAL);
|
|
|
|
#endif
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
void mobile_draw(MOBPAR_FORMAL) {
|
|
|
|
|
|
|
|
optimizeview();
|
|
|
|
|
|
|
|
int lastt = ticks; ticks = getticks();
|
|
|
|
if(lastt > ticks) lastt = ticks;
|
|
|
|
int tdiff = ticks - lastt;
|
|
|
|
|
|
|
|
if(playermoved && vid.sspeed > -4.99)
|
|
|
|
centerpc(tdiff / 1000.0 * exp(vid.sspeed));
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
if(shmup::on && (andmode == 0 || andmode == 10) && size(screens) == 1)
|
2017-03-23 10:53:57 +00:00
|
|
|
shmup::turn(tdiff);
|
|
|
|
|
|
|
|
safety = false;
|
|
|
|
vid.fsize = (min(vid.xres, vid.yres) * fontscale + 50) / 3200;
|
|
|
|
|
2017-06-09 01:41:33 +00:00
|
|
|
mouseoh = mouseh;
|
2017-03-23 10:53:57 +00:00
|
|
|
gtouched = mousepressed = clicked;
|
|
|
|
|
|
|
|
longclick = lclicked && ticks > touchedAt + 500;
|
|
|
|
useRangedOrb =
|
|
|
|
longclick || (!(vid.shifttarget & 2) && haveRangedOrb() && lmouseover && lmouseover->cpdist > 1);
|
|
|
|
|
|
|
|
targetclick = ((vid.shifttarget & 2) && !shmup::on) ? longclick : true;
|
|
|
|
|
|
|
|
if(shmup::on) {
|
|
|
|
using namespace shmupballs;
|
|
|
|
if(hypot(mousex - xfire, mousey - yb) < rad) targetclick = false;
|
|
|
|
if(hypot(mousex - xmove, mousey - yb) < rad) targetclick = false;
|
|
|
|
}
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if(cmode & sm::NORMAL) {
|
2017-03-23 10:53:57 +00:00
|
|
|
lmouseover = (gtouched && lclicked) ? mouseover : NULL;
|
|
|
|
if(!shmup::on && !useRangedOrb && vid.mobilecompasssize) {
|
|
|
|
using namespace shmupballs;
|
|
|
|
int dx = mousex - xmove;
|
|
|
|
int dy = mousey - yb;
|
|
|
|
int h = hypot(dx, dy);
|
|
|
|
if(h < rad) {
|
|
|
|
if(h < rad*SKIPFAC) { lmouseover = cwt.c; mousedest.d = -1; }
|
|
|
|
else {
|
2017-07-10 18:47:38 +00:00
|
|
|
double d = vid.revcontrol ? -1 : 1;
|
2017-03-23 10:53:57 +00:00
|
|
|
mouseh = hpxy(dx * d / rad, dy * d / rad);
|
|
|
|
calcMousedest();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(andmode == 0 && !useRangedOrb && gtouched && lclicked) {
|
|
|
|
lmouseover = mousedest.d >= 0 ? cwt.c->mov[(cwt.spin + mousedest.d) % cwt.c->type] : cwt.c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mouseh = gethyper(mousex, mousey);
|
|
|
|
|
|
|
|
// if(debfile) fprintf(debfile, "d1\n"), fflush(debfile);
|
|
|
|
frames++;
|
|
|
|
if(conformal::on) conformal::apply();
|
|
|
|
|
|
|
|
if(ticks > lastt) tortoise::updateVals(ticks - lastt);
|
|
|
|
|
|
|
|
if(clicked && !lclicked) touchedAt = ticks;
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_XGD
|
2017-03-23 10:53:57 +00:00
|
|
|
graphdata.clear();
|
2017-07-22 23:33:27 +00:00
|
|
|
#endif
|
2017-03-23 10:53:57 +00:00
|
|
|
getcstat = 0; shiftmul = 1; getcshift = 1;
|
|
|
|
drawscreen();
|
|
|
|
shiftmul = getcshift;
|
|
|
|
calcMousedest();
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
inmenu = size(screens) > 1;
|
|
|
|
|
2017-03-23 10:53:57 +00:00
|
|
|
if(lclicked && !clicked && !inmenu) handleclick(MOBPAR_ACTUAL);
|
|
|
|
|
|
|
|
if(inmenu && !clicked && !lclicked) inmenu = false;
|
|
|
|
|
|
|
|
bool keyreact = lclicked && !clicked;
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if(cmode & sm::ZOOMABLE) {
|
2017-03-23 10:53:57 +00:00
|
|
|
using namespace dialog::zoom;
|
2017-07-22 23:33:27 +00:00
|
|
|
if(zoomoff) {
|
2017-03-23 10:53:57 +00:00
|
|
|
zoomf = 1; shiftx = shifty = 0; zoomoff = false; return;
|
|
|
|
}
|
|
|
|
if(clicked && !lclicked) {
|
|
|
|
zoomf = 3;
|
|
|
|
}
|
|
|
|
if(zoomf == 3) {
|
|
|
|
shiftx = -2*mousex;
|
|
|
|
shifty = -2*mousey;
|
|
|
|
}
|
|
|
|
if(!clicked && zoomf > 1) { zoomoff = true; }
|
|
|
|
}
|
|
|
|
|
|
|
|
if(inslider) keyreact = true;
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if CAP_ANDROIDSHARE
|
2017-03-31 19:41:09 +00:00
|
|
|
if(getcstat == 's'-96 && keyreact) {
|
2017-07-22 23:33:27 +00:00
|
|
|
popScreenAll();
|
2017-03-23 10:53:57 +00:00
|
|
|
shareScore(MOBPAR_ACTUAL);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-07-10 18:47:38 +00:00
|
|
|
if(andmode == 2 && size(screens) != 1) andmode = 12;
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if((cmode & sm::NORMAL) && getcstat == '-')
|
|
|
|
getcstat = 0;
|
|
|
|
|
|
|
|
if(keyreact) {
|
|
|
|
handlekey(getcstat, getcstat);
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if ISIOS
|
2017-03-23 10:53:57 +00:00
|
|
|
displayTexts();
|
|
|
|
#endif
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if(clicked && lclicked && andmode == 1 && (cmode & sm::NORMAL)) {
|
|
|
|
if(!mouseout2() && mouseoh[2] < 50 && mouseh[2] < 50) {
|
|
|
|
panning(mouseoh, mouseh);
|
2017-03-23 10:53:57 +00:00
|
|
|
}
|
2017-07-22 23:33:27 +00:00
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if(andmode == 1 && lclicked && !clicked && !inmenu && mouseover)
|
|
|
|
performMarkCommand(mouseover);
|
2017-03-23 10:53:57 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
if(clicked && andmode == 2 && (mouseover != lmouseover || mouseovers != lmouseovers) && !inmenu) {
|
|
|
|
addMessage(mouseovers);
|
|
|
|
lmouseovers = mouseovers;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(andmode == 10 && clicked != lclicked) andmode = 0;
|
|
|
|
if(andmode == 20 && clicked != lclicked) andmode = 10;
|
|
|
|
|
|
|
|
if(andmode == 2 && lclicked && !clicked) {
|
|
|
|
showHelp(MOBPAR_ACTUAL, help);
|
|
|
|
}
|
2017-03-23 10:53:57 +00:00
|
|
|
|
|
|
|
else if(andmode == 4) {
|
|
|
|
achievement_final(false);
|
|
|
|
}
|
|
|
|
|
2017-09-17 11:25:17 +00:00
|
|
|
if(clicked && andmode == 12 && (mouseover != lmouseover || mouseovers != lmouseovers)) {
|
2017-03-23 10:53:57 +00:00
|
|
|
addMessage(mouseovers);
|
|
|
|
lmouseovers = mouseovers;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(clicked != lclicked)
|
|
|
|
flashMessages();
|
|
|
|
|
|
|
|
// END
|
|
|
|
lclicked = clicked;
|
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if ISIOS
|
2017-03-23 10:53:57 +00:00
|
|
|
controlMusic(ticks - lastt);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2017-05-27 19:40:40 +00:00
|
|
|
|
2017-07-22 23:33:27 +00:00
|
|
|
#if !CAP_AUDIO
|
2017-05-27 19:40:40 +00:00
|
|
|
void playSound(cell*, const string &s, int vol) { printf("play sound: %s vol %d\n", s.c_str(), vol); }
|
|
|
|
#endif
|
2017-08-13 18:49:38 +00:00
|
|
|
|