move avatar size changes to Avatar slots

This commit is contained in:
Stephen Birarda 2013-08-15 12:18:19 -07:00
parent 92b6459e4b
commit 811fc87294
5 changed files with 39 additions and 32 deletions

View file

@ -710,10 +710,10 @@ void Application::keyPressEvent(QKeyEvent* event) {
}
break;
case Qt::Key_Plus:
increaseAvatarSize();
_myAvatar.increaseSize();
break;
case Qt::Key_Minus:
decreaseAvatarSize();
_myAvatar.decreaseSize();
break;
case Qt::Key_1:
@ -1142,25 +1142,6 @@ void Application::setFullscreen(bool fullscreen) {
updateCursor();
}
void Application::increaseAvatarSize() {
if ((1.f + SCALING_RATIO) * _myAvatar.getNewScale() < MAX_SCALE) {
_myAvatar.setNewScale((1.f + SCALING_RATIO) * _myAvatar.getNewScale());
qDebug("Changed scale to %f\n", _myAvatar.getNewScale());
}
}
void Application::decreaseAvatarSize() {
if (MIN_SCALE < (1.f - SCALING_RATIO) * _myAvatar.getNewScale()) {
_myAvatar.setNewScale((1.f - SCALING_RATIO) * _myAvatar.getNewScale());
qDebug("Changed scale to %f\n", _myAvatar.getNewScale());
}
}
void Application::resetAvatarSize() {
_myAvatar.setNewScale(1.f);
qDebug("Reseted scale to %f\n", _myAvatar.getNewScale());
}
void Application::setFrustumOffset(bool frustumOffset) {
// reshape so that OpenGL will get the right lens details for the camera of choice
resizeGL(_glWidget->width(), _glWidget->height());

View file

@ -142,10 +142,6 @@ private slots:
void setFullscreen(bool fullscreen);
void increaseAvatarSize();
void decreaseAvatarSize();
void resetAvatarSize();
void renderThrustAtVoxel(const glm::vec3& thrust);
void renderLineToTouchedVoxel();

View file

@ -151,13 +151,21 @@ Menu::Menu() :
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::ParticleSystem);
addCheckableActionToQMenuAndActionHash(renderMenu, MenuOption::FirstPerson, Qt::Key_P, true);
addActionToQMenuAndActionHash(renderMenu, MenuOption::IncreaseAvatarSize);
addActionToQMenuAndActionHash(renderMenu, MenuOption::DecreaseAvatarSize);
addActionToQMenuAndActionHash(renderMenu, MenuOption::ResetAvatarSize);
// renderMenu->addAction("Increase Avatar Size", this, SLOT(increaseAvatarSize()), Qt::Key_Plus);
// renderMenu->addAction("Decrease Avatar Size", this, SLOT(decreaseAvatarSize()), Qt::Key_Minus);
// renderMenu->addAction("Reset Avatar Size", this, SLOT(resetAvatarSize()));
addActionToQMenuAndActionHash(renderMenu,
MenuOption::IncreaseAvatarSize,
Qt::Key_Plus,
appInstance->getAvatar(),
SLOT(increaseSize()));
addActionToQMenuAndActionHash(renderMenu,
MenuOption::DecreaseAvatarSize,
Qt::Key_Minus,
appInstance->getAvatar(),
SLOT(decreaseSize()));
addActionToQMenuAndActionHash(renderMenu,
MenuOption::ResetAvatarSize,
0,
appInstance->getAvatar(),
SLOT(resetSize()));
QMenu* toolsMenu = addMenu("Tools");
addCheckableActionToQMenuAndActionHash(toolsMenu, MenuOption::Stats, Qt::Key_Slash);

View file

@ -1659,6 +1659,25 @@ void Avatar::goHome() {
setPosition(START_LOCATION);
}
void Avatar::increaseSize() {
if ((1.f + SCALING_RATIO) * _newScale < MAX_SCALE) {
_newScale *= (1.f + SCALING_RATIO);
qDebug("Changed scale to %f\n", _newScale);
}
}
void Avatar::decreaseSize() {
if (MIN_SCALE < (1.f - SCALING_RATIO) * _newScale) {
_newScale *= (1.f - SCALING_RATIO);
qDebug("Changed scale to %f\n", _newScale);
}
}
void Avatar::resetSize() {
_newScale = 1.0f;
qDebug("Reseted scale to %f\n", _newScale);
}
void Avatar::setNewScale(const float scale) {
_newScale = scale;
}

View file

@ -215,6 +215,9 @@ public:
public slots:
void setWantCollisionsOn(bool wantCollisionsOn) { _isCollisionsOn = wantCollisionsOn; }
void goHome();
void increaseSize();
void decreaseSize();
void resetSize();
private:
// privatize copy constructor and assignment operator to avoid copying