mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 16:50:06 +00:00 
			
		
		
		
	Add texture types for resource loading and reference
This commit is contained in:
		
							parent
							
								
									64c5d60483
								
							
						
					
					
						commit
						400db66f09
					
				
					 4 changed files with 107 additions and 6 deletions
				
			
		|  | @ -172,7 +172,8 @@ set(HDR_TYPES source/scwx/qt/types/alert_types.hpp | |||
|               source/scwx/qt/types/qt_types.hpp | ||||
|               source/scwx/qt/types/radar_product_record.hpp | ||||
|               source/scwx/qt/types/text_event_key.hpp | ||||
|               source/scwx/qt/types/text_types.hpp) | ||||
|               source/scwx/qt/types/text_types.hpp | ||||
|               source/scwx/qt/types/texture_types.hpp) | ||||
| set(SRC_TYPES source/scwx/qt/types/alert_types.cpp | ||||
|               source/scwx/qt/types/github_types.cpp | ||||
|               source/scwx/qt/types/imgui_font.cpp | ||||
|  | @ -180,7 +181,8 @@ set(SRC_TYPES source/scwx/qt/types/alert_types.cpp | |||
|               source/scwx/qt/types/map_types.cpp | ||||
|               source/scwx/qt/types/radar_product_record.cpp | ||||
|               source/scwx/qt/types/text_event_key.cpp | ||||
|               source/scwx/qt/types/text_types.cpp) | ||||
|               source/scwx/qt/types/text_types.cpp | ||||
|               source/scwx/qt/types/texture_types.cpp) | ||||
| set(HDR_UI source/scwx/qt/ui/about_dialog.hpp | ||||
|            source/scwx/qt/ui/alert_dialog.hpp | ||||
|            source/scwx/qt/ui/alert_dock_widget.hpp | ||||
|  |  | |||
|  | @ -2,6 +2,7 @@ | |||
| #include <scwx/qt/manager/font_manager.hpp> | ||||
| #include <scwx/qt/config/county_database.hpp> | ||||
| #include <scwx/qt/model/imgui_context_model.hpp> | ||||
| #include <scwx/qt/types/texture_types.hpp> | ||||
| #include <scwx/qt/util/texture_atlas.hpp> | ||||
| #include <scwx/util/logger.hpp> | ||||
| 
 | ||||
|  | @ -91,10 +92,19 @@ static void LoadFonts() | |||
| static void LoadTextures() | ||||
| { | ||||
|    util::TextureAtlas& textureAtlas = util::TextureAtlas::Instance(); | ||||
|    textureAtlas.RegisterTexture("lines/default-1x7", | ||||
|                                 ":/res/textures/lines/default-1x7.png"); | ||||
|    textureAtlas.RegisterTexture("lines/test-pattern", | ||||
|                                 ":/res/textures/lines/test-pattern.png"); | ||||
| 
 | ||||
|    for (auto imageTexture : types::ImageTextureIterator()) | ||||
|    { | ||||
|       textureAtlas.RegisterTexture(GetTextureName(imageTexture), | ||||
|                                    GetTexturePath(imageTexture)); | ||||
|    } | ||||
| 
 | ||||
|    for (auto lineTexture : types::LineTextureIterator()) | ||||
|    { | ||||
|       textureAtlas.RegisterTexture(GetTextureName(lineTexture), | ||||
|                                    GetTexturePath(lineTexture)); | ||||
|    } | ||||
| 
 | ||||
|    textureAtlas.BuildAtlas(2048, 2048); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										50
									
								
								scwx-qt/source/scwx/qt/types/texture_types.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								scwx-qt/source/scwx/qt/types/texture_types.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,50 @@ | |||
| #include <scwx/qt/types/texture_types.hpp> | ||||
| 
 | ||||
| #include <unordered_map> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace types | ||||
| { | ||||
| 
 | ||||
| struct TextureInfo | ||||
| { | ||||
|    std::string name_ {}; | ||||
|    std::string path_ {}; | ||||
| }; | ||||
| 
 | ||||
| static const std::unordered_map<ImageTexture, TextureInfo> imageTextureInfo_ { | ||||
|    {ImageTexture::Crosshairs32, | ||||
|     {"images/crosshairs-32", ":/res/textures/images/crosshairs-32.png"}}}; | ||||
| 
 | ||||
| static const std::unordered_map<LineTexture, TextureInfo> lineTextureInfo_ { | ||||
|    {LineTexture::Default1x7, | ||||
|     {"lines/default-1x7", ":/res/textures/lines/default-1x7.png"}}, | ||||
|    {LineTexture::TestPattern, | ||||
|     {"lines/test-pattern", ":/res/textures/lines/test-pattern.png"}}}; | ||||
| 
 | ||||
| const std::string& GetTextureName(ImageTexture imageTexture) | ||||
| { | ||||
|    return imageTextureInfo_.at(imageTexture).name_; | ||||
| } | ||||
| 
 | ||||
| const std::string& GetTextureName(LineTexture lineTexture) | ||||
| { | ||||
|    return lineTextureInfo_.at(lineTexture).name_; | ||||
| } | ||||
| 
 | ||||
| const std::string& GetTexturePath(ImageTexture imageTexture) | ||||
| { | ||||
|    return imageTextureInfo_.at(imageTexture).path_; | ||||
| } | ||||
| 
 | ||||
| const std::string& GetTexturePath(LineTexture lineTexture) | ||||
| { | ||||
|    return lineTextureInfo_.at(lineTexture).path_; | ||||
| } | ||||
| 
 | ||||
| } // namespace types
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
							
								
								
									
										39
									
								
								scwx-qt/source/scwx/qt/types/texture_types.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								scwx-qt/source/scwx/qt/types/texture_types.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,39 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <scwx/util/iterator.hpp> | ||||
| 
 | ||||
| #include <string> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace types | ||||
| { | ||||
| 
 | ||||
| enum class ImageTexture | ||||
| { | ||||
|    Crosshairs32 | ||||
| }; | ||||
| typedef scwx::util::Iterator<ImageTexture, | ||||
|                              ImageTexture::Crosshairs32, | ||||
|                              ImageTexture::Crosshairs32> | ||||
|    ImageTextureIterator; | ||||
| 
 | ||||
| enum class LineTexture | ||||
| { | ||||
|    Default1x7, | ||||
|    TestPattern | ||||
| }; | ||||
| typedef scwx::util:: | ||||
|    Iterator<LineTexture, LineTexture::Default1x7, LineTexture::TestPattern> | ||||
|       LineTextureIterator; | ||||
| 
 | ||||
| const std::string& GetTextureName(ImageTexture imageTexture); | ||||
| const std::string& GetTextureName(LineTexture lineTexture); | ||||
| const std::string& GetTexturePath(ImageTexture imageTexture); | ||||
| const std::string& GetTexturePath(LineTexture lineTexture); | ||||
| 
 | ||||
| } // namespace types
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat