|
|
@ -242,7 +242,7 @@ std::string InputGroup::GetDisplayName(){ |
|
|
|
return combinationDisplay; |
|
|
|
return combinationDisplay; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void InputGroup::DrawInputView(const vf2d pos,const std::string_view displayText,const uint8_t alpha,InputType type)const{ |
|
|
|
void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*const>renderer,const vf2d pos,const std::string_view displayText,const uint8_t alpha,InputType type)const{ |
|
|
|
std::optional<Input>primaryKey; |
|
|
|
std::optional<Input>primaryKey; |
|
|
|
switch(type){ |
|
|
|
switch(type){ |
|
|
|
case CONTROLLER:primaryKey=GetPrimaryKey(CONTROLLER);break; |
|
|
|
case CONTROLLER:primaryKey=GetPrimaryKey(CONTROLLER);break; |
|
|
@ -276,76 +276,34 @@ void InputGroup::DrawInputView(const vf2d pos,const std::string_view displayText |
|
|
|
Pixel buttonTextCol="Interface.InputButtonTextCol"_Pixel; |
|
|
|
Pixel buttonTextCol="Interface.InputButtonTextCol"_Pixel; |
|
|
|
buttonBackCol.a=alpha; |
|
|
|
buttonBackCol.a=alpha; |
|
|
|
buttonTextCol.a=alpha; |
|
|
|
buttonTextCol.a=alpha; |
|
|
|
game->view.FillRectDecal(pos+offset+vf2d{-2.f,0.f},vf2d{textSize.x+4,textSize.y},buttonBackCol); |
|
|
|
|
|
|
|
game->view.FillRectDecal(pos+offset+vf2d{-1.f,-1.f},vf2d{textSize.x+2,textSize.y},buttonBackCol); |
|
|
|
|
|
|
|
game->view.FillRectDecal(pos+offset+vf2d{-1.f,0.f},vf2d{textSize.x+2,textSize.y+1.f},buttonBackCol); |
|
|
|
|
|
|
|
game->view.DrawStringPropDecal(pos+offset+vf2d{0.f,0.f},label,buttonTextCol); |
|
|
|
|
|
|
|
offset.x+=textSize.x+"Interface.InputHelperSpacing"_I; |
|
|
|
|
|
|
|
}else [[unlikely]]ERR("WARNING! Hit a state where no data is inside of the button! THIS SHOULD NOT BE HAPPENING!"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
game->view.DrawShadowStringPropDecal(pos+offset,displayText,{255,255,255,alpha},{0,0,0,alpha}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InputGroup::DrawInputView(const vf2d pos,const std::string_view displayText,const uint8_t alpha)const{ |
|
|
|
#pragma region Render Macro |
|
|
|
InputType primaryType; |
|
|
|
#define Render(rendererType) \ |
|
|
|
if(Input::UsingGamepad())primaryType=CONTROLLER; |
|
|
|
std::get<rendererType*const>(renderer)->FillRectDecal(pos+offset+vf2d{-2.f,0.f},vf2d{textSize.x+4,textSize.y},buttonBackCol); \
|
|
|
|
else if(Menu::UsingMouseNavigation())primaryType=MOUSE; |
|
|
|
std::get<rendererType*const>(renderer)->FillRectDecal(pos+offset+vf2d{-1.f,-1.f},vf2d{textSize.x+2,textSize.y},buttonBackCol); \
|
|
|
|
else primaryType=KEY; |
|
|
|
std::get<rendererType*const>(renderer)->FillRectDecal(pos+offset+vf2d{-1.f,0.f},vf2d{textSize.x+2,textSize.y+1.f},buttonBackCol); \
|
|
|
|
DrawInputView(pos,displayText,alpha,primaryType); |
|
|
|
std::get<rendererType*const>(renderer)->DrawStringPropDecal(pos+offset+vf2d{0.f,0.f},label,buttonTextCol); |
|
|
|
} |
|
|
|
#pragma endregion |
|
|
|
|
|
|
|
|
|
|
|
void InputGroup::DrawInput(const vf2d pos,const std::string_view displayText,const uint8_t alpha,InputType type)const{ |
|
|
|
if(std::holds_alternative<AiL*const>(renderer)){ |
|
|
|
std::optional<Input>primaryKey; |
|
|
|
Render(AiL); |
|
|
|
switch(type){ |
|
|
|
|
|
|
|
case CONTROLLER:primaryKey=GetPrimaryKey(CONTROLLER);break; |
|
|
|
|
|
|
|
case MOUSE:primaryKey=GetPrimaryKey(MOUSE);break; |
|
|
|
|
|
|
|
default:primaryKey=GetPrimaryKey(KEY);break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vf2d buttonImgSize{}; |
|
|
|
|
|
|
|
std::vector<std::variant<Decal*,std::string>>buttonImgs; |
|
|
|
|
|
|
|
if(primaryKey.has_value()){ |
|
|
|
|
|
|
|
if(primaryKey.value().HasIcon()){ |
|
|
|
|
|
|
|
buttonImgSize+=primaryKey.value().GetIcon().Sprite()->Size()+vf2d{"Interface.InputHelperSpacing"_F,"Interface.InputHelperSpacing"_F}; |
|
|
|
|
|
|
|
buttonImgs.push_back(primaryKey.value().GetIcon().Decal()); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
buttonImgSize+=game->GetTextSizeProp(primaryKey.value().GetDisplayName())+vf2d{"Interface.InputHelperSpacing"_F,"Interface.InputHelperSpacing"_F}; |
|
|
|
|
|
|
|
buttonImgs.push_back(primaryKey.value().GetDisplayName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
vf2d descriptionTextSize=game->GetTextSizeProp(displayText); |
|
|
|
|
|
|
|
vf2d offset=-((buttonImgSize+descriptionTextSize)/2.f); |
|
|
|
|
|
|
|
for(auto&button:buttonImgs){ |
|
|
|
|
|
|
|
if(std::holds_alternative<Decal*>(button)){ |
|
|
|
|
|
|
|
Decal*img=std::get<Decal*>(button); |
|
|
|
|
|
|
|
game->view.DrawDecal(pos+offset,img,{1.f,1.f},{255,255,255,alpha}); |
|
|
|
|
|
|
|
offset.x+=img->sprite->width+"Interface.InputHelperSpacing"_I; |
|
|
|
|
|
|
|
}else |
|
|
|
}else |
|
|
|
if(std::holds_alternative<std::string>(button)){ |
|
|
|
if(std::holds_alternative<TileTransformedView*const>(renderer)){ |
|
|
|
std::string label=std::get<std::string>(button); |
|
|
|
Render(TileTransformedView); |
|
|
|
vf2d textSize=game->GetTextSizeProp(label); |
|
|
|
} |
|
|
|
Pixel buttonBackCol="Interface.InputButtonBackCol"_Pixel; |
|
|
|
|
|
|
|
Pixel buttonTextCol="Interface.InputButtonTextCol"_Pixel; |
|
|
|
|
|
|
|
buttonBackCol.a=alpha; |
|
|
|
|
|
|
|
buttonTextCol.a=alpha; |
|
|
|
|
|
|
|
game->FillRectDecal(pos+offset+vf2d{-2.f,0.f},vf2d{textSize.x+4,textSize.y},buttonBackCol); |
|
|
|
|
|
|
|
game->FillRectDecal(pos+offset+vf2d{-1.f,-1.f},vf2d{textSize.x+2,textSize.y},buttonBackCol); |
|
|
|
|
|
|
|
game->FillRectDecal(pos+offset+vf2d{-1.f,0.f},vf2d{textSize.x+2,textSize.y+1.f},buttonBackCol); |
|
|
|
|
|
|
|
game->DrawStringPropDecal(pos+offset+vf2d{0.f,0.f},label,buttonTextCol); |
|
|
|
|
|
|
|
offset.x+=textSize.x+"Interface.InputHelperSpacing"_I; |
|
|
|
offset.x+=textSize.x+"Interface.InputHelperSpacing"_I; |
|
|
|
}else [[unlikely]]ERR("WARNING! Hit a state where no data is inside of the button! THIS SHOULD NOT BE HAPPENING!"); |
|
|
|
}else [[unlikely]]ERR("WARNING! Hit a state where no data is inside of the button! THIS SHOULD NOT BE HAPPENING!"); |
|
|
|
|
|
|
|
|
|
|
|
game->DrawShadowStringPropDecal(pos+offset,displayText,{255,255,255,alpha},{0,0,0,alpha}); |
|
|
|
game->view.DrawShadowStringPropDecal(pos+offset,displayText,{255,255,255,alpha},{0,0,0,alpha}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void InputGroup::DrawInput(const vf2d pos,const std::string_view displayText,const uint8_t alpha)const{ |
|
|
|
void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*const>renderer,const vf2d pos,const std::string_view displayText,const uint8_t alpha)const{ |
|
|
|
InputType primaryType; |
|
|
|
InputType primaryType; |
|
|
|
if(Input::UsingGamepad())primaryType=CONTROLLER; |
|
|
|
if(Input::UsingGamepad())primaryType=CONTROLLER; |
|
|
|
else if(Menu::UsingMouseNavigation())primaryType=MOUSE; |
|
|
|
else if(Menu::UsingMouseNavigation())primaryType=MOUSE; |
|
|
|
else primaryType=KEY; |
|
|
|
else primaryType=KEY; |
|
|
|
DrawInput(pos,displayText,alpha,primaryType); |
|
|
|
DrawInput(renderer,pos,displayText,alpha,primaryType); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const bool Input::HasIcon()const{ |
|
|
|
const bool Input::HasIcon()const{ |
|
|
|