Skip to content

Commit

Permalink
Merge branch 'master' of github.com:saantiaguilera/fiuba-taller-I-meg…
Browse files Browse the repository at this point in the history
…aman
  • Loading branch information
mastanca committed Jul 2, 2016
2 parents 7283ba2 + 0604d91 commit d2ad748
Show file tree
Hide file tree
Showing 23 changed files with 957 additions and 969 deletions.
41 changes: 0 additions & 41 deletions client/concurrent/client_GarbageCollector.h

This file was deleted.

20 changes: 5 additions & 15 deletions client/concurrent/client_Looper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define CLIENT_CLIENT_LOOPER_H_

#include "client_Event.h"
#include "client_GarbageCollector.h"
#include "../../common/common_Mutex.h"
#include "../../common/common_Lock.h"
#include <queue>
Expand All @@ -20,27 +19,19 @@ class Looper {

std::queue<Event*> messagePool;

bool gcRunning;
std::vector<Event*> gcPool;
GarbageCollector *gc;

public:
static Looper& getMainLooper() {
static Looper instance;
return instance;
}

explicit Looper() : gcRunning(true) {
gc = new GarbageCollector(&gcRunning, &gcPool);
gc->start();
explicit Looper() {
}

~Looper() {
if (gcRunning) {
gcRunning = false;
gc->join();

delete gc;
while (messagePool.size() > 0) {
delete messagePool.front();
messagePool.pop();
}
}

Expand All @@ -59,8 +50,7 @@ class Looper {
Lock lock(mutex);

if (!messagePool.empty()) {
if (gcRunning)
gcPool.push_back(messagePool.front());
delete messagePool.front();
messagePool.pop();
}
}
Expand Down
Binary file added doc/MainWindowAppearance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/editorControllerClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/editorMainWindowAppearance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/editorMapFixedWindowClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/editorMapWindowAppearance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/editorMapWindowClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 41 additions & 2 deletions editor/models/dialogs/editor_DialogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,30 @@
#define SAVE_DIALOG_PRIMARY_TEXT "Save"
#define SAVE_DIALOG_SECONDARY_TEXT "Are you sure you want to save this map? changes are irreversible!"

#define MUST_HAVE_MEGAMAN_DIALOG_PRIMARY_TEXT "Validation"
#define MUST_HAVE_MEGAMAN_DIALOG_SECONDARY_TEXT "Map must have a megaman spawner to be saved"

#define MUST_HAVE_BOSS_DIALOG_PRIMARY_TEXT "Validation"
#define MUST_HAVE_BOSS_DIALOG_SECONDARY_TEXT "Map must have a boss to be saved"

#define MUST_HAVE_BOSSCHABER_DIALOG_PRIMARY_TEXT "Validation"
#define MUST_HAVE_BOSSCHABER_DIALOG_SECONDARY_TEXT "Map must have a bosschamber to be saved"

#define BACK_DIALOG_PRIMARY_TEXT "Back withous saving"
#define BACK_DIALOG_SECONDARY_TEXT "Are you sure you whant to go back without saving this map? changes will loose permanently!"



DialogManager::DialogManager(MapWindow *aPresentingWindow) {
presentingWindow = aPresentingWindow;
}


DialogManager::DialogManager() {
}

DialogManager::~DialogManager() {
}


void DialogManager::showSaveDialog() {
Gtk::MessageDialog dialog(*presentingWindow, SAVE_DIALOG_PRIMARY_TEXT,
false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK_CANCEL);
Expand Down Expand Up @@ -65,3 +73,34 @@ void DialogManager::showBackDialog() {
presentingWindow->back();
}
}

void DialogManager::showMustHaveBossDialog() {
Gtk::MessageDialog dialog(*presentingWindow, MUST_HAVE_BOSS_DIALOG_PRIMARY_TEXT,
false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK_CANCEL);

dialog.set_secondary_text(
MUST_HAVE_BOSS_DIALOG_SECONDARY_TEXT);

dialog.run();
}

void DialogManager::showMustHaveBosschamberDialog() {
Gtk::MessageDialog dialog(*presentingWindow, MUST_HAVE_BOSSCHABER_DIALOG_PRIMARY_TEXT,
false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK_CANCEL);

dialog.set_secondary_text(
MUST_HAVE_BOSSCHABER_DIALOG_SECONDARY_TEXT);

dialog.run();
}

void DialogManager::showMustHaveMegamanDialog() {
Gtk::MessageDialog dialog(*presentingWindow, MUST_HAVE_MEGAMAN_DIALOG_PRIMARY_TEXT,
false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK_CANCEL);

dialog.set_secondary_text(
MUST_HAVE_MEGAMAN_DIALOG_SECONDARY_TEXT);

dialog.run();
}

5 changes: 5 additions & 0 deletions editor/models/dialogs/editor_DialogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class DialogManager {
void showSaveDialog();
void showSaveDialogWithBossType(ObstacleViewType aBossType);
void showBackDialog();
void showMustHaveBossDialog();
void showMustHaveBosschamberDialog();
void showMustHaveMegamanDialog();



private:
SaveDelegate *saveDelegate;
Expand Down
59 changes: 59 additions & 0 deletions editor/models/editor_MapWindowValidator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* MapWindowValidator.cpp
*
* Created on: Jul 2, 2016
* Author: santi
*/

#include "editor_MapWindowValidator.h"

#include <iostream>

MapWindowValidator::MapWindowValidator() {
isMegamanSet = true;
isBossSet = true;
isBosschamberSet = true;
}

MapWindowValidator::~MapWindowValidator() {
// TODO Auto-generated destructor stub
}

void MapWindowValidator::setMegaman() {
isMegamanSet = true;
}

void MapWindowValidator::setBoss() {
isBossSet = true;
}

void MapWindowValidator::setBosschamber() {
std::cout << "set boss chamber" << std::boolalpha << isBosschamberSet << std::endl;
isBosschamberSet = true;
std::cout << "did set boss chamber" << std::boolalpha << isBosschamberSet << std::endl;
}

void MapWindowValidator::removeMegaman() {
isMegamanSet = false;
}

void MapWindowValidator::removeBoss() {
isBossSet = false;
}

void MapWindowValidator::removeBosschamber() {
std::cout << "remove boss chamber" << std::boolalpha << isBosschamberSet << std::endl;
isBosschamberSet = false;
std::cout << "did remove boss chamber" << std::boolalpha << isBosschamberSet << std::endl;
}

bool MapWindowValidator::didSetMegaman() {
return isMegamanSet;
}

bool MapWindowValidator::didSetBoss() {
return isBossSet;
}
bool MapWindowValidator::didSetBosschamber() {
return isBosschamberSet;
}
32 changes: 32 additions & 0 deletions editor/models/editor_MapWindowValidator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* MapWindowValidator.h
*
* Created on: Jul 2, 2016
* Author: santi
*/

#ifndef EDITOR_MODELS_EDITOR_MAPWINDOWVALIDATOR_H_
#define EDITOR_MODELS_EDITOR_MAPWINDOWVALIDATOR_H_

class MapWindowValidator {
public:
MapWindowValidator();
virtual ~MapWindowValidator();
void setMegaman();
void setBoss();
void setBosschamber();
void removeMegaman();
void removeBoss();
void removeBosschamber();

bool didSetMegaman();
bool didSetBoss();
bool didSetBosschamber();

private:
bool isMegamanSet;
bool isBossSet;
bool isBosschamberSet;
};

#endif /* EDITOR_MODELS_EDITOR_MAPWINDOWVALIDATOR_H_ */
78 changes: 77 additions & 1 deletion editor/views/editor_MapWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,30 @@ MapWindow::MapWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>&

//Signals
void MapWindow::saveButtonWasTapped() {
//Saving Validation
if (bossEdition) {
if (!validator.didSetBoss()) {
// Did not set bosss => cant save
DialogManager(this).showMustHaveBossDialog();

return;
}
} else {
if (!validator.didSetBosschamber()) {
// Did not set bosschamber => cant save
DialogManager(this).showMustHaveBosschamberDialog();

return;
}

if (!validator.didSetMegaman()) {
// Did not set megaman => cant save
DialogManager(this).showMustHaveMegamanDialog();

return;
}
}

DialogManager(this).showSaveDialog();
}

Expand Down Expand Up @@ -233,6 +257,23 @@ void MapWindow::addDraggingImageWithType(ObstacleViewType obstacleViewType) {

draggingImageContainer = new ObstacleViewContainer(obstacleView);

switch(draggingImageContainer->getObstacleView()->getType()) {
case ObstacleViewTypeMegaman:
validator.setMegaman();
break;
case ObstacleViewTypeBossChamberGate:
std::cout << "set bosschamber" << std::endl;
validator.setBosschamber();
break;
case ObstacleViewTypeFireman:
case ObstacleViewTypeBombman:
case ObstacleViewTypeRingman:
case ObstacleViewTypeSparkman:
case ObstacleViewTypeMagnetman:
validator.setBoss();
break;
}

draggingImage = draggingImageContainer->getImage();
draggingImage->hide();
fixedWindow->setObstacleViewContainer(draggingImageContainer);
Expand Down Expand Up @@ -260,7 +301,6 @@ bool MapWindow::on_button_press_event(GdkEventButton *event) {

// Have to add a new tile
} else if (event->button == kLeftClickButton) {

// Deside whether image have to be drop or just move it
if (draggingImageIsMoving) {
dropDraggingImage(event->x, event->y);
Expand Down Expand Up @@ -324,6 +364,23 @@ void MapWindow::dragImage(int aX, int aY) {
return;
}

switch(obstacleViewContainer->getObstacleView()->getType()) {
case ObstacleViewTypeMegaman :
validator.removeMegaman();
break;
case ObstacleViewTypeBossChamberGate :
validator.removeBosschamber();
break;
case ObstacleViewTypeFireman:
case ObstacleViewTypeBombman:
case ObstacleViewTypeRingman:
case ObstacleViewTypeSparkman:
case ObstacleViewTypeMagnetman:
validator.removeBoss();
break;
default: break;
}

draggingImageContainer = obstacleViewContainer;

draggingImage = draggingImageContainer->getImage();
Expand All @@ -332,6 +389,7 @@ void MapWindow::dragImage(int aX, int aY) {
void MapWindow::deleteDraggingImage() {
draggingEnd();


draggingImage = 0;
fixedWindow->removeObstacleContainerView(draggingImageContainer);
}
Expand All @@ -341,6 +399,24 @@ void MapWindow::deleteImage(int aX, int aY) {
if (obstacleViewContainerToRemove == NULL) {
return;
}

switch(obstacleViewContainerToRemove->getObstacleView()->getType()) {
case ObstacleViewTypeMegaman :
validator.removeMegaman();
break;
case ObstacleViewTypeBossChamberGate :

validator.removeBosschamber();
break;
case ObstacleViewTypeFireman:
case ObstacleViewTypeBombman:
case ObstacleViewTypeRingman:
case ObstacleViewTypeSparkman:
case ObstacleViewTypeMagnetman:
validator.removeBoss();
break;
}

fixedWindow->removeObstacleContainerView(obstacleViewContainerToRemove);
}

Expand Down
Loading

0 comments on commit d2ad748

Please sign in to comment.