fixed/extended the mouse zoom etc.

This commit is contained in:
Zeno Rogue 2017-12-30 17:00:35 +01:00
parent d3e789bc93
commit 154bd54607
3 changed files with 47 additions and 31 deletions

View File

@ -656,6 +656,9 @@ void mainloopiter() {
bool rollchange = (cmode & sm::OVERVIEW) && getcstat >= 2000 && cheater;
bool anyctrl = keystate[SDLK_LCTRL] || keystate[SDLK_RCTRL];
bool anyshift = keystate[SDLK_LSHIFT] || keystate[SDLK_RSHIFT];
if(ev.type == SDL_MOUSEBUTTONDOWN || ev.type == SDL_MOUSEBUTTONUP) {
mousepressed = ev.type == SDL_MOUSEBUTTONDOWN;
if(mousepressed) flashMessages();
@ -670,10 +673,7 @@ void mainloopiter() {
else {
act = actonrelease && ev.type == SDL_MOUSEBUTTONUP;
actonrelease = ev.type == SDL_MOUSEBUTTONDOWN;
}
bool anyctrl = keystate[SDLK_LCTRL] || keystate[SDLK_RCTRL];
bool anyshift = keystate[SDLK_LSHIFT] || keystate[SDLK_RSHIFT];
}
if(ev.type != SDL_MOUSEMOTION) fix_mouseh();
@ -681,20 +681,23 @@ void mainloopiter() {
else if(ev.button.button==SDL_BUTTON_RIGHT || leftclick)
sym = SDLK_F1;
else if(ev.button.button==SDL_BUTTON_MIDDLE || rightclick)
else if(ev.button.button==SDL_BUTTON_MIDDLE || rightclick) {
sym = 1, didsomething = true;
if(anyshift)
vid.xposition = vid.yposition = 0;
}
else if(ev.button.button == SDL_BUTTON_LEFT) {
sym = getcstat, uni = getcstat, shiftmul = getcshift;
}
else if(ev.button.button==SDL_BUTTON_WHEELDOWN) {
if(anyctrl && anyshift) {
vid.scale /= 1.2;
if(anyctrl && anyshift && !rug::rugged) {
mapeditor::scaleall(1/1.2);
vid.alpha /= 1.2;
}
else if(anyctrl)
vid.scale *= pow(2, -.25);
else if(anyshift)
else if(anyctrl && !rug::rugged)
mapeditor::scaleall(pow(2, -.25));
else if(anyshift && !rug::rugged)
vid.alpha -= 0.25;
else if(rollchange) {
sym = getcstat, uni = getcstat, shiftmul = getcshift, wheelclick = true;
@ -704,13 +707,13 @@ void mainloopiter() {
}
}
if(ev.button.button==SDL_BUTTON_WHEELUP) {
if(anyctrl && anyshift) {
vid.scale *= 1.2;
if(anyctrl && anyshift && !rug::rugged) {
mapeditor::scaleall(1.2);
vid.alpha *= 1.2;
}
else if(anyctrl)
vid.scale *= pow(2, .25);
else if(anyshift)
else if(anyctrl && !rug::rugged)
mapeditor::scaleall(pow(2, .25));
else if(anyshift && !rug::rugged)
vid.alpha += 0.25;
else if(rollchange) {
sym = getcstat, uni = getcstat, shiftmul = -getcshift, wheelclick = true;
@ -724,6 +727,8 @@ void mainloopiter() {
if(ev.type == SDL_MOUSEMOTION) {
mouseoh = mouseh;
int lmousex = mousex, lmousey = mousey;
mousing = true;
mousemoved = true;
mousex = ev.motion.x;
@ -731,11 +736,17 @@ void mainloopiter() {
need_mouseh = true;
if(holdmouse && getcstat == '-') sym = uni = getcstat;
if(holdmouse && getcstat == '-') sym = uni = getcstat, fix_mouseh();
if((rightclick || (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_MMASK)) && !mouseout2() &&
mouseh[2] < 50 && mouseoh[2] < 50) {
panning(mouseoh, mouseh);
if((rightclick || (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON_MMASK)) && !mouseout2()) {
fix_mouseh();
if(anyctrl) {
vid.xposition += (mousex - lmousex) * 1. / vid.scrsize,
vid.yposition += (mousey - lmousey) * 1. / vid.scrsize;
}
else if(mouseh[2] < 50 && mouseoh[2] < 50) {
panning(mouseoh, mouseh);
}
}
#ifdef SIMULATE_JOYSTICK
@ -755,7 +766,7 @@ void mainloopiter() {
if(needConfirmation() && !(cmode & sm::MISSION)) showMissionScreen();
else quitmainloop = true;
}
handlekey(sym, uni);
}
@ -797,10 +808,10 @@ void displayabutton(int px, int py, string s, int col) {
#endif
void gmodekeys(int sym, int uni) {
if(uni == '1') { vid.alpha = 999; vid.scale = 998; vid.xposition = vid.yposition = 0; }
if(uni == '2') { vid.alpha = 1; vid.scale = 0.4; vid.xposition = vid.yposition = 0; }
if(uni == '3') { vid.alpha = 1; vid.scale = 1; vid.xposition = vid.yposition = 0; }
if(uni == '4') { vid.alpha = 0; vid.scale = 1; vid.xposition = vid.yposition = 0; }
if(uni == '1' && !rug::rugged) { vid.alpha = 999; vid.scale = 998; vid.xposition = vid.yposition = 0; }
if(uni == '2' && !rug::rugged) { vid.alpha = 1; vid.scale = 0.4; vid.xposition = vid.yposition = 0; }
if(uni == '3' && !rug::rugged) { vid.alpha = 1; vid.scale = 1; vid.xposition = vid.yposition = 0; }
if(uni == '4' && !rug::rugged) { vid.alpha = 0; vid.scale = 1; vid.xposition = vid.yposition = 0; }
if(uni == '5') { vid.wallmode += 60 + (shiftmul > 0 ? 1 : -1); vid.wallmode %= 6; }
if(uni == '6') vid.grid = !vid.grid;
if(uni == '7') { vid.darkhepta = !vid.darkhepta; }

View File

@ -2390,6 +2390,8 @@ namespace texture {
void remap(eTextureState old_tstate, eTextureState old_tstate_max);
void perform_mapping();
void undoLock();
void undo();
extern bool texturesym;

View File

@ -1000,8 +1000,6 @@ namespace mapeditor {
}
displaymm('g', vid.xres-8, 8+fs*4, 2, vid.fsize, XLAT("g = grid"), 16);
displaymm('z', vid.xres-8, 8+fs*3, 2, vid.fsize, XLAT("z = zoom in"), 16);
displaymm('o', vid.xres-8, 8+fs*2, 2, vid.fsize, XLAT("o = zoom out"), 16);
if(intexture) for(int i=0; i<10; i++) {
if(8 + fs * (6+i) < vid.yres - 8 - fs * 7)
@ -1333,12 +1331,20 @@ namespace mapeditor {
ld mrx = (.0 + mousex - vid.xcenter) / vid.scale;
ld mry = (.0 + mousey - vid.ycenter) / vid.scale;
vid.xposition += (vid.scale - vid.scale*z) * mrx / vid.scrsize;
vid.yposition += (vid.scale - vid.scale*z) * mry / vid.scrsize;
if(vid.xres > vid.yres) {
vid.xposition += (vid.scale - vid.scale*z) * mrx / vid.scrsize;
vid.yposition += (vid.scale - vid.scale*z) * mry / vid.scrsize;
}
vid.scale *= z;
printf("scale = " LDF "\n", vid.scale);
#if CAP_TEXTURE
texture::itt = xyscale(texture::itt, 1/z);
display(texture::itt);
if(texture::tstate) {
calcparam();
texture::perform_mapping();
}
#endif
}
@ -1383,9 +1389,6 @@ namespace mapeditor {
if(mkuni == 'g')
coldcenter = ccenter, ccenter = mh, clickused = true;
if(mkuni == 'z') scaleall(2), clickused = true;
if(mkuni == 'o') scaleall(.5), clickused = true;
if(uni == ' ' && cheater) {
popScreen();
pushScreen(showMapEditor);