1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 13:07:16 +00:00

rogueviz:: presentation:: replace_hud and latex_in_space

This commit is contained in:
Zeno Rogue 2024-08-01 12:22:29 +02:00
parent 73ed8aedf4
commit aaaef26bae
2 changed files with 48 additions and 0 deletions

View File

@ -76,6 +76,11 @@ void no_other_hud(presmode mode) {
clearMessages();
}
void replace_hud(presmode mode, reaction_t f) {
add_temporary_hook(mode, hooks_prestats, 300, [f] { f(); return true; });
clearMessages();
}
/** disable all the HyperRogue game stuff */
void non_game_slide(presmode mode) {
if(mode == pmStart) {
@ -309,6 +314,47 @@ void dialog_may_latex(string latex, string normal, color_t col, int size, flagty
}
}
map<string, basic_textureinfo> finf_of;
void latex_in_space(const shiftmatrix& V, ld scale, string s, color_t col, flagtype flags) {
string fn = gen_latex(pmStart, s, 600, flags);
if(!textures.count(fn)) {
gen_latex(pmStartAll, s, 600, flags);
auto& tex = textures[fn];
tex.original = true;
tex.twidth = 4096;
println(hlog, "rt = ", tex.readtexture(fn));
if(!(flags & LATEX_COLOR))
for(int y=0; y<tex.theight; y++)
for(int x=0; x<tex.twidth; x++) {
auto& pix = tex.get_texture_pixel(x, y);
if(y <= tex.base_y || y >= tex.base_y + tex.stry || x <= tex.base_x || x >= tex.base_x + tex.strx) { pix = 0; continue; }
int dark = 255 - part(pix, 1);
pix = 0xFFFFFF + (dark << 24);
}
println(hlog, "gl = ", tex.loadTextureGL());
println(hlog, "fn is ", fn);
}
auto& finf = finf_of[fn];
auto& tex = textures[fn];
finf.texture_id = tex.textureid;
finf.tvertices.clear();
static vector<glhr::textured_vertex> rtver(4);
ld tx = tex.tx;
ld ty = tex.ty;
for(int i=0; i<6; i++) {
ld cx[6] = {1,0,0,1,1,0};
ld cy[6] = {1,1,0,1,0,0};
finf.tvertices.push_back(glhr::makevertex((tex.base_x + (cx[i] ? tex.strx : 0.)) / tex.twidth, (tex.base_y + (cy[i] ? tex.stry : 0.)) / tex.theight, 0));
curvedata.push_back(glhr::pointtogl(point31((cx[i]*2-1) * tx * scale, (cy[i]*2-1) * ty * scale, 0)));
}
auto &res = queuetable(V, curvedata, isize(curvedata)-curvestart, col, col, PPR::LINE);
res.offset = curvestart;
res.offset_texture = 0;
res.tinf = &finf;
res.flags |= POLY_TRIANGLES;
curvestart = isize(curvedata);
}
int video_start = 0;
void read_all(int fd, void *buf, int cnt) {

View File

@ -257,6 +257,7 @@ function<void(presmode)> roguevizslide_action(char c, const T& t, const U& act)
void add_stat(presmode mode, const bool_reaction_t& stat);
void compare_projections(presmode mode, eModel a, eModel b);
void no_other_hud(presmode mode);
void replace_hud(presmode mode, reaction_t f);
void non_game_slide(presmode mode);
void non_game_slide_scroll(presmode mode);
void white_screen(presmode mode, color_t col = 0xFFFFFFFF);
@ -274,6 +275,7 @@ function<void(presmode)> roguevizslide_action(char c, const T& t, const U& act)
void dialog_may_latex(string latex, string normal, color_t col = dialog::dialogcolor, int size = 100, flagtype flag = 0);
void uses_game(presmode mode, string name, reaction_t launcher, reaction_t restore);
void latex_slide(presmode mode, string s, flagtype flags = 0, int size = 100);
void latex_in_space(const shiftmatrix& V, ld scale, string s, color_t col, flagtype flags);
inline purehookset hooks_latex_slide;