Skip to content

Commit

Permalink
fix warning+exit crash, fix menusection offset resetting when menus a…
Browse files Browse the repository at this point in the history
…re rebuilt
  • Loading branch information
jacob1 committed Jun 25, 2016
1 parent 083d488 commit 4190946
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/gui/game/Favorite.cpp
Expand Up @@ -23,4 +23,4 @@ bool Favorite::IsFavorite(std::string identifier)
{
std::vector<std::string> tempFavoritsList = *favoritesList;
return std::find(tempFavoritsList.begin(), tempFavoritsList.end(), identifier) != tempFavoritsList.end();
}
}
6 changes: 4 additions & 2 deletions src/gui/game/GameModel.cpp
Expand Up @@ -166,6 +166,8 @@ GameModel::~GameModel()

for (size_t i = 0; i < menuList.size(); i++)
{
if (i == SC_FAVORITES)
menuList[i]->ClearTools();
delete menuList[i];
}
for (std::vector<Tool*>::iterator iter = extraElementTools.begin(), end = extraElementTools.end(); iter != end; ++iter)
Expand Down Expand Up @@ -370,12 +372,12 @@ void GameModel::BuildFavoritesMenu()
{
menuList[SC_FAVORITES]->ClearTools();

for (int i = 0; i < menuList.size(); i++)
for (size_t i = 0; i < menuList.size(); i++)
{
if (i == SC_FAVORITES)
continue;

for (int j = 0; j < menuList[i]->GetToolList().size(); j++)
for (size_t j = 0; j < menuList[i]->GetToolList().size(); j++)
{
if (Favorite::Ref().IsFavorite(menuList[i]->GetToolList()[j]->GetIdentifier()))
{
Expand Down
10 changes: 8 additions & 2 deletions src/gui/game/GameView.cpp
Expand Up @@ -538,11 +538,13 @@ class GameView::ToolAction: public ui::ButtonAction
void ActionCallback(ui::Button * sender_)
{
ToolButton *sender = (ToolButton*)sender_;
if (v->ShiftBehaviour() && !v->CtrlBehaviour() && !v->AltBehaviour())
if (v->ShiftBehaviour() && v->CtrlBehaviour() && !v->AltBehaviour())

This comment has been minimized.

Copy link
@me4502

me4502 Jun 26, 2016

Contributor

Why change it to CTRL+SHIFT?

This comment has been minimized.

Copy link
@jacob1

jacob1 Jun 26, 2016

Author Member

Uh, I think it was to match my mod, but I actually forgot I did this and I could probably change it back (I will probably just throw out the favorites menu in my mod as it is right now because it is extremely glitchy)

This comment has been minimized.

Copy link
@me4502

me4502 Jun 26, 2016

Contributor

Ah, okay - I just had it shift because it's simpler to click, but your choice.

{
if (Favorite::Ref().IsFavorite(tool->GetIdentifier()) && sender->GetSelectionState() == 1)
{
Favorite::Ref().GetFavoritesList()->erase(std::remove(Favorite::Ref().GetFavoritesList()->begin(), Favorite::Ref().GetFavoritesList()->end(),
tool->GetIdentifier()), Favorite::Ref().GetFavoritesList()->end());
}
else if (sender->GetSelectionState() == 0)
Favorite::Ref().GetFavoritesList()->push_back(tool->GetIdentifier());
else if (sender->GetSelectionState() == 2)
Expand Down Expand Up @@ -728,7 +730,6 @@ void GameView::NotifyLastToolChanged(GameModel * sender)

void GameView::NotifyToolListChanged(GameModel * sender)
{
lastOffset = 0;
int currentX = WINDOWW-56;
for (size_t i = 0; i < menuButtons.size(); i++)
{
Expand Down Expand Up @@ -795,6 +796,11 @@ void GameView::NotifyToolListChanged(GameModel * sender)
}
if (sender->GetActiveMenu() != SC_DECO)
lastMenu = sender->GetActiveMenu();

// don't reset scroll back to 0
int origOffset = lastOffset;
lastOffset = 0;
setToolButtonOffset(origOffset);
}

void GameView::NotifyColourSelectorVisibilityChanged(GameModel * sender)
Expand Down

0 comments on commit 4190946

Please sign in to comment.