Fix up warnings (mostly loss of data cast warnings). When an ability gets interrupted, the key is required to be depressed before another cast attempt can be made. Added collision layer tiles to a few tiles in 1-1 due to ability to walk out-of-bounds.
This commit is contained in:
+16
-16
@@ -70,12 +70,12 @@ typedef Attribute A;
|
||||
|
||||
Menu::Menu(vf2d pos,vf2d size)
|
||||
:pos(pos==CENTERED?WINDOW_SIZE/2-size/2:vi2d{pos}),size(size){
|
||||
r.Create(size.x,size.y);
|
||||
r.Create(uint32_t(size.x),uint32_t(size.y));
|
||||
overlay.Create(WINDOW_SIZE.x,WINDOW_SIZE.y);
|
||||
}
|
||||
|
||||
Menu::~Menu(){
|
||||
for(auto key:components){
|
||||
for(auto&key:components){
|
||||
delete key.second;
|
||||
}
|
||||
}
|
||||
@@ -128,17 +128,17 @@ Menu*Menu::CreateMenu(MenuType type,vf2d pos,vf2d size){
|
||||
void Menu::AddComponent(std::string key,MenuComponent*button){
|
||||
if(button->selectable){
|
||||
buttons.Unlock();
|
||||
if(buttons.count(button->rect.pos.y)){
|
||||
buttons.at(button->rect.pos.y).push_back(button);
|
||||
if(buttons.count(int(button->rect.pos.y))){
|
||||
buttons.at(int(button->rect.pos.y)).push_back(button);
|
||||
}else{
|
||||
buttons[button->rect.pos.y].push_back(button);
|
||||
buttons[int(button->rect.pos.y)].push_back(button);
|
||||
}
|
||||
if(button->selectableViaKeyboard){
|
||||
keyboardButtons.Unlock();
|
||||
if(keyboardButtons.count(button->rect.pos.y)){
|
||||
keyboardButtons.at(button->rect.pos.y).push_back(button);
|
||||
if(keyboardButtons.count(int(button->rect.pos.y))){
|
||||
keyboardButtons.at(int(button->rect.pos.y)).push_back(button);
|
||||
}else{
|
||||
keyboardButtons[button->rect.pos.y].push_back(button);
|
||||
keyboardButtons[int(button->rect.pos.y)].push_back(button);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,11 +147,11 @@ void Menu::AddComponent(std::string key,MenuComponent*button){
|
||||
keyboardButtons.SetInitialized();
|
||||
|
||||
//We make an assumption that menu components are supposed to be in left-to-right order. Sometimes we may add things out-of-order, so this fixes the problem by sorting the items afterwards.
|
||||
std::sort(buttons[button->rect.pos.y].begin(),buttons[button->rect.pos.y].end(),[](MenuComponent*c1,MenuComponent*c2){
|
||||
std::sort(buttons[int(button->rect.pos.y)].begin(),buttons[int(button->rect.pos.y)].end(),[](MenuComponent*c1,MenuComponent*c2){
|
||||
return c1->GetPos().x<c2->GetPos().x;
|
||||
});
|
||||
if(keyboardButtons.count(button->rect.pos.y)){ //Keyboard buttons may not necessarily contain this key...Let's be sure.
|
||||
std::sort(keyboardButtons[button->rect.pos.y].begin(),keyboardButtons[button->rect.pos.y].end(),[](MenuComponent*c1,MenuComponent*c2){
|
||||
if(keyboardButtons.count(int(button->rect.pos.y))){ //Keyboard buttons may not necessarily contain this key...Let's be sure.
|
||||
std::sort(keyboardButtons[int(button->rect.pos.y)].begin(),keyboardButtons[int(button->rect.pos.y)].end(),[](MenuComponent*c1,MenuComponent*c2){
|
||||
return c1->GetPos().x<c2->GetPos().x;
|
||||
});
|
||||
}
|
||||
@@ -395,7 +395,7 @@ void Menu::KeyboardButtonNavigation(Crawler*game,vf2d menuPos){
|
||||
if(selection==vi2d{-1,-1})return;
|
||||
selection.x--;
|
||||
SetMouseNavigation(false);
|
||||
if(selection.x<0)selection.x+=keyboardButtons[selection.y].size();
|
||||
if(selection.x<0)selection.x+=int32_t(keyboardButtons[selection.y].size());
|
||||
}
|
||||
if(game->GetKey(DOWN).bPressed||game->GetKey(UP).bPressed){
|
||||
if(game->GetKey(DOWN).bPressed){
|
||||
@@ -411,7 +411,7 @@ void Menu::KeyboardButtonNavigation(Crawler*game,vf2d menuPos){
|
||||
}else{
|
||||
for(auto&key:keyboardButtons){
|
||||
if(found){ //Once we discover the previous element, the next element becomes our next selection.
|
||||
int previousButtonX=keyboardButtons[selection.y][selection.x]->rect.pos.x;
|
||||
int previousButtonX=int(keyboardButtons[selection.y][selection.x]->rect.pos.x);
|
||||
selection.y=key.first;
|
||||
int index=0;
|
||||
for(auto&button:key.second){ //Try to match a button in the same column as this button first.
|
||||
@@ -456,7 +456,7 @@ void Menu::KeyboardButtonNavigation(Crawler*game,vf2d menuPos){
|
||||
prevInd=key.first;
|
||||
}
|
||||
if(prevInd!=-1){
|
||||
int previousButtonX=keyboardButtons[selection.y][selection.x]->rect.pos.x;
|
||||
int previousButtonX=int(keyboardButtons[selection.y][selection.x]->rect.pos.x);
|
||||
selection.y=prevInd;
|
||||
int index=0;
|
||||
for(auto&button:keyboardButtons[prevInd]){ //Try to match a button in the same column as this button first.
|
||||
@@ -687,9 +687,9 @@ bool Menu::IsMenuOpen(){
|
||||
}
|
||||
|
||||
void Menu::CleanupAllMenus(){
|
||||
for(auto key:Menu::menus){
|
||||
for(auto&key:Menu::menus){
|
||||
Menu*menu=key.second;
|
||||
for(auto componentKey:menu->components){
|
||||
for(auto&componentKey:menu->components){
|
||||
MenuComponent*component=componentKey.second;
|
||||
component->Cleanup();
|
||||
delete component;
|
||||
|
||||
Reference in New Issue
Block a user