mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Fixed first batch of locale-dependent calls
This commit is contained in:
		
							parent
							
								
									5a1441f9b7
								
							
						
					
					
						commit
						9ee2fc8275
					
				
					 6 changed files with 52 additions and 60 deletions
				
			
		|  | @ -1457,7 +1457,7 @@ void PageDiameters::apply_custom_config(DynamicPrintConfig &config) | |||
|     config.set_key_value("filament_diameter", opt_filam); | ||||
| 
 | ||||
|     auto set_extrusion_width = [&config, opt_nozzle](const char *key, double dmr) { | ||||
|         char buf[64]; | ||||
|         char buf[64]; // locales don't matter here (sprintf/atof)
 | ||||
|         sprintf(buf, "%.2lf", dmr * opt_nozzle->values.front() / 0.4); | ||||
|         config.set_key_value(key, new ConfigOptionFloatOrPercent(atof(buf), false)); | ||||
|     }; | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ | |||
| #include "libslic3r/Geometry.hpp" | ||||
| #include "libslic3r/Model.hpp" | ||||
| #include "libslic3r/Utils.hpp" | ||||
| #include "libslic3r/LocalesUtils.hpp" | ||||
| #include "GUI_App.hpp" | ||||
| #include "MainFrame.hpp" | ||||
| #include "Plater.hpp" | ||||
|  | @ -78,6 +79,7 @@ static float round_to_nearest(float value, unsigned int decimals) | |||
|         res = std::round(value); | ||||
|     else { | ||||
|         char buf[64]; | ||||
|         // locales should not matter, both sprintf and stof are sensitive, so...
 | ||||
|         sprintf(buf, "%.*g", decimals, value); | ||||
|         res = std::stof(buf); | ||||
|     } | ||||
|  | @ -3465,18 +3467,16 @@ void GCodeViewer::render_statistics() const | |||
|     ImGuiWrapper& imgui = *wxGetApp().imgui(); | ||||
| 
 | ||||
|     auto add_time = [this, &imgui](const std::string& label, int64_t time) { | ||||
|         char buf[1024]; | ||||
|         sprintf(buf, "%lld ms (%s)", time, get_time_dhms(static_cast<float>(time) * 0.001f).c_str()); | ||||
|         imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, label); | ||||
|         ImGui::SameLine(offset); | ||||
|         imgui.text(buf); | ||||
|         imgui.text(std::to_string(time) + " ms (" + get_time_dhms(static_cast<float>(time) * 0.001f) + ")"); | ||||
|     }; | ||||
| 
 | ||||
|     auto add_memory = [this, &imgui](const std::string& label, int64_t memory) { | ||||
|         auto format_string = [memory](const std::string& units, float value) { | ||||
|             char buf[1024]; | ||||
|             sprintf(buf, "%lld bytes (%.3f %s)", memory, static_cast<float>(memory) * value, units.c_str()); | ||||
|             return std::string(buf); | ||||
|         auto format_string = [memory](const std::string& units, float value) {             | ||||
|             return std::to_string(memory) + " bytes (" + | ||||
|                    Slic3r::float_to_string_decimal_point(float(memory) * value, 3) | ||||
|                     + " " + units + ")"; | ||||
|         }; | ||||
| 
 | ||||
|         static const float kb = 1024.0f; | ||||
|  | @ -3496,11 +3496,9 @@ void GCodeViewer::render_statistics() const | |||
|     }; | ||||
| 
 | ||||
|     auto add_counter = [this, &imgui](const std::string& label, int64_t counter) { | ||||
|         char buf[1024]; | ||||
|         sprintf(buf, "%lld", counter); | ||||
|         imgui.text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, label); | ||||
|         ImGui::SameLine(offset); | ||||
|         imgui.text(buf); | ||||
|         imgui.text(std::to_string(counter)); | ||||
|     }; | ||||
| 
 | ||||
|     imgui.set_next_window_pos(0.5f * wxGetApp().plater()->get_current_canvas3D()->get_canvas_size().get_width(), 0.0f, ImGuiCond_Once, 0.5f, 0.0f); | ||||
|  |  | |||
|  | @ -1586,7 +1586,7 @@ bool GUI_App::load_language(wxString language, bool initial) | |||
|     m_wxLocale->AddCatalog(SLIC3R_APP_KEY); | ||||
|     m_imgui->set_language(into_u8(language_info->CanonicalName)); | ||||
|     //FIXME This is a temporary workaround, the correct solution is to switch to "C" locale during file import / export only.
 | ||||
|     wxSetlocale(LC_NUMERIC, "C"); | ||||
|     //wxSetlocale(LC_NUMERIC, "C");
 | ||||
|     Preset::update_suffix_modified((" (" + _L("modified") + ")").ToUTF8().data()); | ||||
| 	return true; | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lukas Matena
						Lukas Matena