Implemented proper steam icon displays for all users of DrawInput (base camp NPCs). Release Build 8339.
This commit is contained in:
		
							parent
							
								
									db5b071689
								
							
						
					
					
						commit
						5016dc9b66
					
				| @ -568,7 +568,17 @@ std::string InputGroup::GetDisplayName(){ | |||||||
| 
 | 
 | ||||||
| void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*const,ViewPort*const>renderer,const vf2d pos,const std::string_view displayText,const uint8_t alpha,InputType type,vf2d textScale)const{ | void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*const,ViewPort*const>renderer,const vf2d pos,const std::string_view displayText,const uint8_t alpha,InputType type,vf2d textScale)const{ | ||||||
| 	std::vector<Input>displayKeys; | 	std::vector<Input>displayKeys; | ||||||
|  | 
 | ||||||
|  | 	auto OriginalGameIcon=[](std::optional<Input>input)->bool{ | ||||||
|  | 		if(input.has_value()){ | ||||||
|  | 			EInputActionOrigin action=Input::steamGameInputToOrigin.at(Steam::SteamInput(input.value().key)).second[0]; | ||||||
|  | 			return Input::steamIconToGameIcon.count(action); | ||||||
|  | 		} | ||||||
|  | 		return true; | ||||||
|  | 	}; | ||||||
|  | 
 | ||||||
| 	switch(type){ | 	switch(type){ | ||||||
|  | 		case STEAM:std::copy_if(keys.begin(),keys.end(),std::back_inserter(displayKeys),[](const Input&input){return input.GetType()==STEAM;});break; | ||||||
| 		case CONTROLLER:std::copy_if(keys.begin(),keys.end(),std::back_inserter(displayKeys),[](const Input&input){return input.GetType()==CONTROLLER;});break; | 		case CONTROLLER:std::copy_if(keys.begin(),keys.end(),std::back_inserter(displayKeys),[](const Input&input){return input.GetType()==CONTROLLER;});break; | ||||||
| 		case MOUSE:std::copy_if(keys.begin(),keys.end(),std::back_inserter(displayKeys),[](const Input&input){return input.GetType()==KEY||input.GetType()==MOUSE;});break; | 		case MOUSE:std::copy_if(keys.begin(),keys.end(),std::back_inserter(displayKeys),[](const Input&input){return input.GetType()==KEY||input.GetType()==MOUSE;});break; | ||||||
| 		default:std::copy_if(keys.begin(),keys.end(),std::back_inserter(displayKeys),[](const Input&input){return input.GetType()==KEY||input.GetType()==MOUSE;});break; | 		default:std::copy_if(keys.begin(),keys.end(),std::back_inserter(displayKeys),[](const Input&input){return input.GetType()==KEY||input.GetType()==MOUSE;});break; | ||||||
| @ -584,8 +594,14 @@ void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*cons | |||||||
| 			buttonImgs.push_back(input.GetIcon(GameSettings::GetIconType()).Decal()); | 			buttonImgs.push_back(input.GetIcon(GameSettings::GetIconType()).Decal()); | ||||||
| 		}else | 		}else | ||||||
| 		if(input.HasIcon()){ | 		if(input.HasIcon()){ | ||||||
| 			buttonImgSize.x+=input.GetIcon().Sprite()->width*textScale.x+"Interface.InputHelperSpacing"_F; | 			float alteredIconScale=1.f; | ||||||
| 			buttonImgSize.y=std::max(buttonImgSize.y,float(input.GetIcon().Sprite()->height)); | 			 | ||||||
|  | 			if(type==STEAM&&!OriginalGameIcon(input)){ | ||||||
|  | 				alteredIconScale/=2.85f; //They are initially 32x32.
 | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			buttonImgSize.x+=input.GetIcon().Sprite()->width*alteredIconScale*textScale.x+"Interface.InputHelperSpacing"_F; | ||||||
|  | 			buttonImgSize.y=std::max(buttonImgSize.y,float(input.GetIcon().Sprite()->height*alteredIconScale)); | ||||||
| 			buttonImgs.push_back(input.GetIcon().Decal()); | 			buttonImgs.push_back(input.GetIcon().Decal()); | ||||||
| 		}else{ | 		}else{ | ||||||
| 			buttonImgSize.x+=game->GetTextSizeProp(input.GetDisplayName()).x*textScale.x+"Interface.InputHelperSpacing"_F; | 			buttonImgSize.x+=game->GetTextSizeProp(input.GetDisplayName()).x*textScale.x+"Interface.InputHelperSpacing"_F; | ||||||
| @ -596,10 +612,11 @@ void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*cons | |||||||
| 
 | 
 | ||||||
| 	vf2d descriptionTextSize=game->GetTextSizeProp(displayText); | 	vf2d descriptionTextSize=game->GetTextSizeProp(displayText); | ||||||
| 	vf2d offset=-((buttonImgSize+descriptionTextSize)/2.f); | 	vf2d offset=-((buttonImgSize+descriptionTextSize)/2.f); | ||||||
| 	for(auto&button:buttonImgs){ | 	for(size_t index=0;auto&button:buttonImgs){ | ||||||
| 		if(std::holds_alternative<Decal*>(button)){ | 		if(std::holds_alternative<Decal*>(button)){ | ||||||
| 			Decal*img=std::get<Decal*>(button); | 			Decal*img=std::get<Decal*>(button); | ||||||
| 
 | 			float alteredIconScale=1.f; | ||||||
|  | 			if(type==STEAM&&!OriginalGameIcon(displayKeys[index]))alteredIconScale/=2.85f; /*They are initially 32x32.*/ | ||||||
| 			#pragma region Render Macro | 			#pragma region Render Macro | ||||||
| 			#define Render(rendererType) \ | 			#define Render(rendererType) \ | ||||||
| 				std::get<rendererType*const>(renderer)->DrawDecal(pos+offset-vf2d{0.f,2.f},img,textScale,{255,255,255,alpha}); | 				std::get<rendererType*const>(renderer)->DrawDecal(pos+offset-vf2d{0.f,2.f},img,textScale,{255,255,255,alpha}); | ||||||
| @ -613,7 +630,7 @@ void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*cons | |||||||
| 			if(std::holds_alternative<ViewPort*const>(renderer)){ | 			if(std::holds_alternative<ViewPort*const>(renderer)){ | ||||||
| 				Render(ViewPort); | 				Render(ViewPort); | ||||||
| 			}else ERR("Could not find proper renderer for rendering Inputs!"); | 			}else ERR("Could not find proper renderer for rendering Inputs!"); | ||||||
| 			offset.x+=img->sprite->width*textScale.x+"Interface.InputHelperSpacing"_I; | 			offset.x+=img->sprite->width*alteredIconScale*textScale.x+"Interface.InputHelperSpacing"_I; | ||||||
| 		}else | 		}else | ||||||
| 		if(std::holds_alternative<std::string>(button)){ | 		if(std::holds_alternative<std::string>(button)){ | ||||||
| 			std::string label=std::get<std::string>(button); | 			std::string label=std::get<std::string>(button); | ||||||
| @ -642,6 +659,7 @@ void InputGroup::DrawInput(const std::variant<AiL*const,TileTransformedView*cons | |||||||
| 			}else ERR("Could not find proper renderer for rendering Inputs!"); | 			}else ERR("Could not find proper renderer for rendering Inputs!"); | ||||||
| 			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!"); | ||||||
|  | 		index++; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	#pragma region Render Display Text | 	#pragma region Render Display Text | ||||||
| @ -739,12 +757,10 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi | |||||||
| 	for(auto&button:buttonImgs){ | 	for(auto&button:buttonImgs){ | ||||||
| 		if(std::holds_alternative<Decal*>(button)){ | 		if(std::holds_alternative<Decal*>(button)){ | ||||||
| 			Decal*img=std::get<Decal*>(button); | 			Decal*img=std::get<Decal*>(button); | ||||||
| 
 | 			float alteredIconScale=1.f; | ||||||
|  | 			if(type==STEAM&&!OriginalGameIcon(primaryKey))alteredIconScale/=2.85f; /*They are initially 32x32.*/ | ||||||
| 			#pragma region Render Macro | 			#pragma region Render Macro | ||||||
| 			#define Render(rendererType) \ | 			#define Render(rendererType) \ | ||||||
| 				float alteredIconScale=1.f; \ |  | ||||||
| 				 \ |  | ||||||
| 				if(type==STEAM&&!OriginalGameIcon(primaryKey))alteredIconScale/=2.85f; /*They are initially 32x32.*/ \ |  | ||||||
| 				std::get<rendererType*const>(renderer)->DrawDecal(pos+offset-vf2d{0.f,2.f},img,alteredIconScale*textScale,{255,255,255,alpha}); | 				std::get<rendererType*const>(renderer)->DrawDecal(pos+offset-vf2d{0.f,2.f},img,alteredIconScale*textScale,{255,255,255,alpha}); | ||||||
| 			#pragma endregion | 			#pragma endregion | ||||||
| 			if(std::holds_alternative<AiL*const>(renderer)){ | 			if(std::holds_alternative<AiL*const>(renderer)){ | ||||||
| @ -756,7 +772,7 @@ void InputGroup::DrawPrimaryInput(const std::variant<AiL*const,TileTransformedVi | |||||||
| 			if(std::holds_alternative<ViewPort*const>(renderer)){ | 			if(std::holds_alternative<ViewPort*const>(renderer)){ | ||||||
| 				Render(ViewPort); | 				Render(ViewPort); | ||||||
| 			}else ERR("Could not find proper renderer for rendering Inputs!"); | 			}else ERR("Could not find proper renderer for rendering Inputs!"); | ||||||
| 			offset.x+=img->sprite->width*textScale.x+"Interface.InputHelperSpacing"_I; | 			offset.x+=img->sprite->width*alteredIconScale*textScale.x+"Interface.InputHelperSpacing"_I; | ||||||
| 		}else | 		}else | ||||||
| 		if(std::holds_alternative<std::string>(button)){ | 		if(std::holds_alternative<std::string>(button)){ | ||||||
| 			std::string label=std::get<std::string>(button); | 			std::string label=std::get<std::string>(button); | ||||||
|  | |||||||
| @ -39,7 +39,7 @@ All rights reserved. | |||||||
| #define VERSION_MAJOR 0 | #define VERSION_MAJOR 0 | ||||||
| #define VERSION_MINOR 5 | #define VERSION_MINOR 5 | ||||||
| #define VERSION_PATCH 1 | #define VERSION_PATCH 1 | ||||||
| #define VERSION_BUILD 8336 | #define VERSION_BUILD 8339 | ||||||
| 
 | 
 | ||||||
| #define stringify(a) stringify_(a) | #define stringify(a) stringify_(a) | ||||||
| #define stringify_(a) #a | #define stringify_(a) #a | ||||||
|  | |||||||
										
											Binary file not shown.
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user