Author Topic: [HOW TO] Enable right click on mini map  (Read 5842 times)

ttsmj

  • Guest
[HOW TO] Enable right click on mini map
« on: 4 July 2008, 21:43:28 »
I will show you how you can enable Right-Click on minimap feature. It allows you to quickly send units to any location on the minimap

What you need
You must have source code of glest version 3.1.2
You need a text editor
You must know how to compile code.

Let's go

1. Open gui/gui.h

Find this on line 177:
Code: [Select]
void giveDefaultOrders(int x, int y);
Replace it by:

Code: [Select]
void giveDefaultOrders(Vec2i targetPos);
Go to line 169 and add this:
Code: [Select]
void mouseDownLeftMinimap(int x, int y);
void mouseDownRightMinimap(int x, int y);

(must be in public section)

2. Open gui/gui.cpp

Add this to line 221:
Code: [Select]
void Gui::mouseDownLeftMinimap(int x, int y){
if(!isSelectingPos()){
gameCamera->setPos(Vec2f(static_cast<float>(x), static_cast<float>(y)));
}
}

void Gui::mouseDownRightMinimap(int one, int two){
if(!isSelectingPos()){
if(selection.isComandable()){
Vec2i targetPos;
targetPos.x= one;
targetPos.y= two;
// go
giveDefaultOrders(targetPos);
}
}
}

Find this on line 217:

Code: [Select]
giveDefaultOrders(x, y);
Replace by:

Code: [Select]
// compute target
Vec2i targetPos;
const Unit *targetUnit= NULL;
if(computeTarget(Vec2i(x, y), targetPos, targetUnit)){
giveDefaultOrders(targetPos);
} else {
console->addStdMessage("InvalidPosition");
}


Find:

Code: [Select]
void Gui::giveDefaultOrders(int x, int y){

//compute target
const Unit *targetUnit= NULL;
Vec2i targetPos;
if(!computeTarget(Vec2i(x, y), targetPos, targetUnit)){
console->addStdMessage("InvalidPosition");
return;
}

Replace by:

Code: [Select]
void Gui::giveDefaultOrders(Vec2i targetPos){

//compute target
const Unit *targetUnit= NULL;

3. Open game/game.cpp

Find on line 381:

Code: [Select]
if(!gui.isSelectingPos()){
gameCamera.setPos(Vec2f(static_cast<float>(xCell), static_cast<float>(yCell)));
}

Replace by:

Code: [Select]
gui.mouseDownLeftMinimap(xCell, yCell);    
Find:

Code: [Select]
void Game::mouseDownRight(int x, int y){
gui.mouseDownRightGraphics(x, y);
}

Replace by:

Code: [Select]
void Game::mouseDownRight(int x, int y){
Map *map= world.getMap();
const Metrics &metrics= Metrics::getInstance();

//minimap panel
if(metrics.isInMinimap(x, y) && !gui.isSelectingPos()){
   
int xm= x - metrics.getMinimapX();
int ym= y - metrics.getMinimapY();
int xCell= static_cast<int>(xm * (static_cast<float>(map->getW()) / metrics.getMinimapW()));
int yCell= static_cast<int>(map->getH() - ym * (static_cast<float>(map->getH()) / metrics.getMinimapH()));

if(map->isInside(xCell, yCell)){

gui.mouseDownRightMinimap(xCell, yCell);    
}
} else {
gui.mouseDownRightGraphics(x, y);
}
}



THAT'S ALL! COMPILE & ENJOY!
« Last Edit: 1 January 1970, 00:00:00 by ttsmj »

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
(No subject)
« Reply #1 on: 4 July 2008, 22:14:17 »
It looks neat, but too complex to be worth the time. Where do you get the source code anyway?

BTW, does this really belong in bug report?
« Last Edit: 1 January 1970, 00:00:00 by omega »
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

ttsmj

  • Guest
(No subject)
« Reply #2 on: 4 July 2008, 22:20:51 »
Quote from: "omega"
It looks neat, but too complex to be worth the time. Where do you get the source code anyway?

BTW, does this really belong in bug report?


I SAID: You must know how to compile code.  
WTH ARE YOU DOING IN THIS THREAD THEN?
« Last Edit: 1 January 1970, 00:00:00 by ttsmj »

hailstone

  • GAE Team
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
(No subject)
« Reply #3 on: 5 July 2008, 05:14:15 »
Good work ttsmj. I agree with omega, though, this should be in Mods or GAE since its not really a bug rather a feature.

I will try this when I get the chance.
« Last Edit: 1 January 1970, 00:00:00 by hailstone »
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

Platyhelminth

  • Guest
(No subject)
« Reply #4 on: 5 July 2008, 06:13:19 »
I compiled it for 64 bit linux (some users may want a binary: http://www.mediafire.com/?5yzgkmnouym ). This fix seems to work.
« Last Edit: 1 January 1970, 00:00:00 by Platyhelminth »

@kukac@

  • Guest
topic
« Reply #5 on: 5 July 2008, 09:06:50 »
Very impressive, I just don't understand, why is it in the bug reports...
« Last Edit: 1 January 1970, 00:00:00 by @kukac@ »

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
(No subject)
« Reply #6 on: 5 July 2008, 17:38:35 »
ttsmj, I know a bit about compiling codes, but I merely stated that it would take a while and unless you have a lot of time, you may not want to do this.

BTW, I already compiled the code and it works, but it took me a long time.  :-X
« Last Edit: 1 January 1970, 00:00:00 by omega »
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

Nihilirian

  • Guest
(No subject)
« Reply #7 on: 6 July 2008, 21:28:32 »
Quote from: "@kukac@"
Very impressive, I just don't understand, why is it in the bug reports...


I think it is a bug-fix.

Because this is so damn annoying. I too thought at first that not being able to right click on the map is a bug rather than intentionally left out .

BUT NOT at all important - it is fixed right?!
« Last Edit: 1 January 1970, 00:00:00 by Nihilirian »

ttsmj

  • Guest
(No subject)
« Reply #8 on: 6 July 2008, 21:31:51 »
Sorry, there is one bug (in bug fix yeah).. People who tried it maybe experienced it :)
This topic was not meant as an final solution but rather as an example how it could be fixed..

Anyways here in ZIP is a new fix. It is meant to be applied on top of 3.1.2 sources

http://www.mediafire.com/?mbetymenyua

If you want to use it, copy the fixed source files (game.cpp , gui.cpp , gui.h) on 3.1.2 source and recompile.

There are also diffs.. They show what exactly I added to (changed in) the original 3.1.2 source

CHEERS
« Last Edit: 1 January 1970, 00:00:00 by ttsmj »

hailstone

  • GAE Team
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
(No subject)
« Reply #9 on: 6 July 2008, 22:45:20 »
I tried to add it to GAE and found it already there, but applied a bit differently. The location beacon appears in the wrong spot though.
« Last Edit: 1 January 1970, 00:00:00 by hailstone »
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
(No subject)
« Reply #10 on: 7 July 2008, 18:19:50 »
This isnt necessary. In regular glest, once a unit(s) selected, left click n the map. This will go to that place on the map. Now move once there. It works, not as good, but it is good for people who either have no time to compile this , don't want to, or can't.
« Last Edit: 1 January 1970, 00:00:00 by omega »
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

Platyhelminth

  • Guest
(No subject)
« Reply #11 on: 9 July 2008, 02:06:58 »
Quote
This isnt necessary. In regular glest, once a unit(s) selected, left click n the map. This will go to that place on the map. Now move once there. It works, not as good, but it is good for people who either have no time to compile this , don't want to, or can't.


 As Hailstone said, this feature is present in GAE mod. GAE is already compiled for windows . And I suspect that ttsmj was inspired by reading GAE code when he did his code :) .
« Last Edit: 1 January 1970, 00:00:00 by Platyhelminth »

ttsmj

  • Guest
(No subject)
« Reply #12 on: 13 July 2008, 17:57:00 »
Quote from: "hailstone"
I tried to add it to GAE and found it already there, but applied a bit differently. The location beacon appears in the wrong spot though.


So it is already fixed in GAE? Then I did the same work again  :-[

Looks like old Glest is almost dead. impossible to push custom fixes into official release. Can I join the GAE developement to avoid forking? But I don't know what all is different in gae? for example i don't like the idea - good vs evil
« Last Edit: 1 January 1970, 00:00:00 by ttsmj »

@kukac@

  • Guest
topic
« Reply #13 on: 13 July 2008, 19:49:07 »
You should check in the GAE forum (or ask someone from the GAE team) for more information.
« Last Edit: 1 January 1970, 00:00:00 by @kukac@ »

hailstone

  • GAE Team
  • Battle Machine
  • ********
  • Posts: 1,568
    • View Profile
(No subject)
« Reply #14 on: 14 July 2008, 11:29:57 »
Daniel hasn't been on for a while. Just submit patches and try doing tasks on the todo list. All the GAE information that I know of is publicly available.
« Last Edit: 1 January 1970, 00:00:00 by hailstone »
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/