Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load the game on double click on the loading menu #243

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions source/glest_game/menu/main_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ void MainMenu::mouseDownLeft(int x, int y){
state->mouseClick(x, y, mbLeft);
}

void MainMenu::mouseDoubleClickLeft(int x, int y){
if(GraphicComponent::getFade()<0.2f) return;
state->mouseDoubleClick(x, y, mbLeft);
}

void MainMenu::mouseDoubleClickRight(int x, int y){
if(GraphicComponent::getFade()<0.2f) return;
state->mouseDoubleClick(x, y, mbRight);
}

void MainMenu::mouseDownRight(int x, int y){
if(GraphicComponent::getFade()<0.2f) return;
state->mouseClick(x, y, mbRight);
Expand Down
3 changes: 3 additions & 0 deletions source/glest_game/menu/main_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class MainMenu: public ProgramState {
virtual void mouseMove(int x, int y, const MouseState *mouseState);
virtual void eventMouseWheel(int x, int y,int zDelta);
virtual void mouseDownLeft(int x, int y);
virtual void mouseDoubleClickLeft(int x, int y);
virtual void mouseDoubleClickRight(int x, int y);
virtual void mouseDownRight(int x, int y);
virtual void mouseUpLeft(int x, int y);
virtual bool textInput(std::string text);
Expand Down Expand Up @@ -119,6 +121,7 @@ class MenuState {
MenuState(Program *program, MainMenu *mainMenu, const string &stateName);
virtual ~MenuState();
virtual void mouseClick(int x, int y, MouseButton mouseButton)=0;
virtual void mouseDoubleClick(int x, int y, MouseButton mouseButton)=0;
virtual void mouseUp(int x, int y, const MouseButton mouseButton){};
virtual void mouseMove(int x, int y, const MouseState *mouseState)=0;
virtual void eventMouseWheel(int x, int y, int zDelta){};
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_about.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class MenuStateAbout: public MenuState{
virtual ~MenuStateAbout();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseMove(int x, int y, const MouseState *mouseState);
void render();
virtual void keyDown(SDL_KeyboardEvent key);
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_connected_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class MenuStateConnectedGame: public MenuState, public FTPClientCallbackInterfac
virtual ~MenuStateConnectedGame();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseMove(int x, int y, const MouseState *mouseState);
void eventMouseWheel(int x, int y,int zDelta);
void render();
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_custom_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ class MenuStateCustomGame : public MenuState, public SimpleTaskCallbackInterface
virtual ~MenuStateCustomGame();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseMove(int x, int y, const MouseState *mouseState);
void eventMouseWheel(int x, int y,int zDelta);
void render();
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_graphic_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class MenuStateGraphicInfo: public MenuState {
MenuStateGraphicInfo(Program *program, MainMenu *mainMenu);

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseMove(int x, int y, const MouseState *mouseState);
void render();
virtual void keyDown(SDL_KeyboardEvent key);
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_join_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class MenuStateJoinGame: public MenuState, public DiscoveredServersInterface {
virtual ~MenuStateJoinGame();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseMove(int x, int y, const MouseState *mouseState);
void render();
void update();
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_keysetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class MenuStateKeysetup: public MenuState {
virtual ~MenuStateKeysetup();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseUp(int x, int y, const MouseButton mouseButton);
void mouseMove(int x, int y, const MouseState *mouseState);
void update();
Expand Down
5 changes: 5 additions & 0 deletions source/glest_game/menu/menu_state_load_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ void MenuStateLoadGame::reloadUI() {
GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName);
}

void MenuStateLoadGame::mouseDoubleClick(int x, int y, MouseButton mouseButton) {
if (mouseButton == mbLeft && selectedButton != NULL && selectedButton->mouseClick(x, y)) {
mouseClick(loadButton.getX()+1, loadButton.getY()+1, mouseButton);
}
}
void MenuStateLoadGame::mouseClick(int x, int y, MouseButton mouseButton){

CoreData &coreData= CoreData::getInstance();
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_load_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class MenuStateLoadGame: public MenuState{
~MenuStateLoadGame();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton);
void mouseUp(int x, int y, const MouseButton mouseButton);
void mouseMove(int x, int y, const MouseState *mouseState);
void update();
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_masterserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class MenuStateMasterserver : public MenuState, public SimpleTaskCallbackInterfa
~MenuStateMasterserver();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseUp(int x, int y, const MouseButton mouseButton);
void mouseMove(int x, int y, const MouseState *mouseState);
void update();
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_mods.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class MenuStateMods: public MenuState, public FTPClientCallbackInterface, public
virtual ~MenuStateMods();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseUp(int x, int y, const MouseButton mouseButton);
void mouseMove(int x, int y, const MouseState *mouseState);
void eventMouseWheel(int x, int y,int zDelta);
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_new_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class MenuStateNewGame: public MenuState{
MenuStateNewGame(Program *program, MainMenu *mainMenu);

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseMove(int x, int y, const MouseState *mouseState);
void update();
void render();
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class MenuStateOptions: public MenuState{
virtual ~MenuStateOptions();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseMove(int x, int y, const MouseState *mouseState);
void render();
virtual bool textInput(std::string text);
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_options_graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class MenuStateOptionsGraphics: public MenuState{
MenuStateOptionsGraphics(Program *program, MainMenu *mainMenu, ProgramState **parentUI=NULL);

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseMove(int x, int y, const MouseState *mouseState);
void render();
//virtual void keyDown(SDL_KeyboardEvent key);
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_options_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class MenuStateOptionsNetwork: public MenuState{
MenuStateOptionsNetwork(Program *program, MainMenu *mainMenu, ProgramState **parentUI=NULL);

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseMove(int x, int y, const MouseState *mouseState);
void render();
//virtual void keyDown(SDL_KeyboardEvent key);
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_options_sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class MenuStateOptionsSound: public MenuState{
MenuStateOptionsSound(Program *program, MainMenu *mainMenu, ProgramState **parentUI=NULL);

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseMove(int x, int y, const MouseState *mouseState);
void render();
//virtual void keyDown(SDL_KeyboardEvent key);
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_root.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class MenuStateRoot: public MenuState, public SimpleTaskCallbackInterface, publi
virtual ~MenuStateRoot();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseMove(int x, int y, const MouseState *mouseState);
void render();
void update();
Expand Down
1 change: 1 addition & 0 deletions source/glest_game/menu/menu_state_scenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class MenuStateScenario: public MenuState {
virtual ~MenuStateScenario();

void mouseClick(int x, int y, MouseButton mouseButton);
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
void mouseMove(int x, int y, const MouseState *mouseState);
void eventMouseWheel(int x, int y,int zDelta);
void render();
Expand Down