1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-07-19 01:12:49 +00:00

adjusted mobile to the new system

This commit is contained in:
Zeno Rogue 2020-04-06 08:37:22 +02:00
parent 548f1d3c1e
commit 9a84dfb497
10 changed files with 47 additions and 27 deletions

View File

@ -607,11 +607,11 @@ EX void resetGL() {
vector<int> graphdata; vector<int> graphdata;
void gdpush(int t) { EX void gdpush(int t) {
graphdata.push_back(t); graphdata.push_back(t);
} }
bool displaychr(int x, int y, int shift, int size, char chr, color_t col) { EX bool displaychr(int x, int y, int shift, int size, char chr, color_t col) {
gdpush(2); gdpush(x); gdpush(y); gdpush(8); gdpush(2); gdpush(x); gdpush(y); gdpush(8);
gdpush(col); gdpush(size); gdpush(0); gdpush(col); gdpush(size); gdpush(0);
gdpush(1); gdpush(chr); gdpush(1); gdpush(chr);

View File

@ -1965,7 +1965,11 @@ EX void draw_main() {
if(ray::in_use && ray::comparison_mode) { if(ray::in_use && ray::comparison_mode) {
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
#ifdef GLES_ONLY
glClearDepthf(1.0f);
#else
glClearDepth(1.0f); glClearDepth(1.0f);
#endif
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
ray::cast(); ray::cast();
} }

View File

@ -5,6 +5,7 @@
#define MOBPAR_FORMAL int #define MOBPAR_FORMAL int
#define MOBPAR_ACTUAL 0 #define MOBPAR_ACTUAL 0
#define MIX_MAX_VOLUME 128 #define MIX_MAX_VOLUME 128
#define NOMAIN
#include <string> #include <string>
namespace hr { namespace hr {
@ -40,6 +41,8 @@ transmatrix getOrientation() {
return Orient; return Orient;
} }
void resetmusic() { printf("resetmusic\n"); }
void playSound(cell *c, const string& fname, int vol) { void playSound(cell *c, const string& fname, int vol) {
printf("Play sound: %s\n", fname.c_str()); printf("Play sound: %s\n", fname.c_str());
} }

View File

@ -35,6 +35,7 @@ EX int hyper_main(int argc, char **argv) {
using namespace hr; using namespace hr;
#if ISWEB #if ISWEB
emscripten_get_commandline(); emscripten_get_commandline();
#elif ISMOBILE
#else #else
arg::init(argc, argv); arg::init(argc, argv);
#endif #endif

View File

@ -130,5 +130,6 @@
namespace hr { namespace daily { bool on; } } namespace hr { namespace daily { bool on; } }
#endif #endif
#include "mobile.cpp"
#include "hyper-main.cpp" #include "hyper-main.cpp"

View File

@ -22,6 +22,7 @@
#define CAP_VERTEXBUFFER 0 #define CAP_VERTEXBUFFER 0
#define CAP_TIMEOFDAY 1 #define CAP_TIMEOFDAY 1
#define NO_STD_HYPOT #define NO_STD_HYPOT
#define NOMAIN
#define HNEW 1 #define HNEW 1
@ -60,7 +61,7 @@ bool settingsChanged = false;
struct transmatrix getOrientation(); struct transmatrix getOrientation();
} }
#include "../../../../../init.cpp" #include "../../../../../hyper.cpp"
namespace hr { namespace hr {
@ -168,19 +169,19 @@ Java_com_roguetemple_hyperroid_HyperRogue_glhrinit(MOBPAR_FORMAL)
extern "C" int extern "C" int
Java_com_roguetemple_hyperroid_HyperRogue_getaPosition(MOBPAR_FORMAL) Java_com_roguetemple_hyperroid_HyperRogue_getaPosition(MOBPAR_FORMAL)
{ {
return glhr::aPosition; return aPosition;
} }
extern "C" int extern "C" int
Java_com_roguetemple_hyperroid_HyperRogue_getaTexture(MOBPAR_FORMAL) Java_com_roguetemple_hyperroid_HyperRogue_getaTexture(MOBPAR_FORMAL)
{ {
return glhr::aTexture; return aTexture;
} }
extern "C" int extern "C" int
Java_com_roguetemple_hyperroid_HyperRogue_getuColor(MOBPAR_FORMAL) Java_com_roguetemple_hyperroid_HyperRogue_getuColor(MOBPAR_FORMAL)
{ {
return glhr::current->uColor; return glhr::current_glprogram->uColor;
} }
const char *scorefile; const char *scorefile;
@ -289,7 +290,7 @@ extern "C" void Java_com_roguetemple_hyperroid_HyperRogue_draw(MOBPAR_FORMAL) {
glhr::be_nontextured(); glhr::be_nontextured();
#if CAP_SHADER #if CAP_SHADER
glEnableVertexAttribArray(glhr::aPosition); glEnableVertexAttribArray(aPosition);
#else #else
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
#endif #endif
@ -349,8 +350,11 @@ extern "C" void Java_com_roguetemple_hyperroid_HyperRogue_update
// delref; // delref;
// if(debfile) fprintf(debfile, "update stopped.\n"), fflush(debfile); // if(debfile) fprintf(debfile, "update stopped.\n"), fflush(debfile);
} }
void resetmusic() {}
void playSound(cell *c, const string& fname, int vol) { void playSound(cell *c, const string& fname, int vol) {
LATE( hr::playSound(c, fname, vol); )
soundsToPlay.push_back(make_pair(fname, vol)); soundsToPlay.push_back(make_pair(fname, vol));
} }

View File

@ -8,8 +8,6 @@
#include "hyper.h" #include "hyper.h"
namespace hr { namespace hr {
#if CU_INIT
#if ISANDROID #if ISANDROID
string buildScoreDescription() { string buildScoreDescription() {
string s; string s;
@ -50,7 +48,9 @@ string buildScoreDescription() {
int andmode; int andmode;
bool lclicked = false, clicked = false; bool lclicked = false;
EX bool clicked = false;
EX bool buttonclicked = false;
string lmouseovers; string lmouseovers;
bool inmenu = false; bool inmenu = false;
@ -90,9 +90,9 @@ void handleclick(MOBPAR_FORMAL) {
else if(statkeys && getcstat == 't') { else if(statkeys && getcstat == 't') {
if(playermoved && items[itStrongWind]) { if(playermoved && items[itStrongWind]) {
cell *c = whirlwind::jumpDestination(cwt.at); cell *c = whirlwind::jumpDestination(cwt.at);
if(c) centerover.at = c, centerover.spin = 0; if(c) centerover = c;
} }
targetRangedOrb(centerover.at, roKeyboard); targetRangedOrb(centerover, roKeyboard);
getcstat = 0; getcstat = 0;
} }
@ -112,7 +112,7 @@ void handleclick(MOBPAR_FORMAL) {
ors::reset(); ors::reset();
centerpc(INF); centerpc(INF);
View = Id; View = Id;
centerover = cwt.at->master; centerover = cwt.at;
} }
andmode = 11; andmode = 11;
} }
@ -151,7 +151,7 @@ void handleclick(MOBPAR_FORMAL) {
if(!playerfound) { if(!playerfound) {
centerpc(INF); centerpc(INF);
View = Id; View = Id;
centerover = cwt.at->master; centerover = cwt.at;
} }
playermoved = true; playermoved = true;
} }
@ -198,7 +198,7 @@ void apply_orientation() {
} }
#endif #endif
void mobile_draw(MOBPAR_FORMAL) { EX void mobile_draw(MOBPAR_FORMAL) {
apply_memory_reserve(); apply_memory_reserve();
optimizeview(); optimizeview();
@ -358,7 +358,7 @@ void mobile_draw(MOBPAR_FORMAL) {
lticks_rug = ticks; lticks_rug = ticks;
if(andmode == 1 && lclicked && !clicked && normal_reaction && mouseover) if(andmode == 1 && lclicked && !clicked && normal_reaction && mouseover)
performMarkCommand(mouseover); mine::performMarkCommand(mouseover);
if(clicked && andmode == 2 && (mouseover != lmouseover || mouseovers != lmouseovers) && normal_reaction) { if(clicked && andmode == 2 && (mouseover != lmouseover || mouseovers != lmouseovers) && normal_reaction) {
addMessage(mouseovers); addMessage(mouseovers);
@ -394,10 +394,4 @@ void mobile_draw(MOBPAR_FORMAL) {
#endif #endif
#if !CAP_AUDIO
void playSound(cell*, const string &s, int vol) { printf("play sound: %s vol %d\n", s.c_str(), vol); }
#endif
#endif
} }

View File

@ -63,7 +63,9 @@ struct renderbuffer {
struct resetbuffer { struct resetbuffer {
GLint drawFboId, readFboId; GLint drawFboId, readFboId;
#if CAP_SDL
SDL_Surface *sreset; SDL_Surface *sreset;
#endif
resetbuffer(); resetbuffer();
void reset(); void reset();
}; };

View File

@ -14,9 +14,14 @@ bool hide_hud = true;
namespace shot { void default_screenshot_content(); } namespace shot { void default_screenshot_content(); }
#endif #endif
#if CAP_SVG
// svg renderer // svg renderer
EX namespace svg { EX namespace svg {
#if !CAP_SVG
EX always_false in;
#endif
#if CAP_SVG
#if ISWEB #if ISWEB
shstream f; shstream f;
#else #else
@ -225,8 +230,9 @@ int read_args() {
auto ah = addHook(hooks_args, 0, read_args); auto ah = addHook(hooks_args, 0, read_args);
#endif #endif
EX }
#endif #endif
EX }
#if CAP_PNG #if CAP_PNG
void IMAGESAVE(SDL_Surface *s, const char *fname) { void IMAGESAVE(SDL_Surface *s, const char *fname) {

View File

@ -8,6 +8,11 @@
#include "hyper.h" #include "hyper.h"
namespace hr { namespace hr {
#if HDR
void playSound(cell *c, const string& fname, int vol = 100);
void resetmusic();
#endif
EX const char *musicfile = ""; EX const char *musicfile = "";
EX bool audio; EX bool audio;
EX string musiclicense; EX string musiclicense;
@ -215,7 +220,7 @@ string wheresounds = HYPERPATH "sounds/";
hookset<bool(const string& s, int vol)> *hooks_sound; hookset<bool(const string& s, int vol)> *hooks_sound;
EX void playSound(cell *c, const string& fname, int vol IS(100)) { EX void playSound(cell *c, const string& fname, int vol) {
LATE( hr::playSound(c, fname, vol); ) LATE( hr::playSound(c, fname, vol); )
if(effvolume == 0) return; if(effvolume == 0) return;
if(callhandlers(false, hooks_sound, fname, vol)) return; if(callhandlers(false, hooks_sound, fname, vol)) return;
@ -284,8 +289,8 @@ auto ah_sound = addHook(hooks_args, 0, read_sound_args) + addHook(hooks_clear_ca
#endif #endif
#if !CAP_SDLAUDIO #if !CAP_AUDIO
EX void playSound(cell *c, const string& fname, int vol IS(100)) { } EX void playSound(cell *c, const string& fname, int vol) { }
EX void resetmusic() { } EX void resetmusic() { }
#endif #endif