2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "debugging/debugging.h"
28 #include "stream/stringstream.h"
29 #include "versionlib.h"
31 #include "mainframe.h"
33 typedef std::map<CopiedString, CopiedString> Variables;
34 Variables g_build_variables;
36 void build_clear_variables(){
37 g_build_variables.clear();
40 void build_set_variable( const char* name, const char* value ){
41 g_build_variables[name] = value;
44 const char* build_get_variable( const char* name ){
45 Variables::iterator i = g_build_variables.find( name );
46 if ( i != g_build_variables.end() ) {
47 return ( *i ).second.c_str();
49 globalErrorStream() << "undefined build variable: " << makeQuoted( name ) << "\n";
54 #include "xml/xmlelement.h"
59 virtual ~Evaluatable() = default;
60 virtual void evaluate( StringBuffer& output ) = 0;
61 virtual void exportXML( XMLImporter& importer ) = 0;
64 class VariableString : public Evaluatable
66 CopiedString m_string;
68 VariableString() : m_string(){
70 VariableString( const char* string ) : m_string( string ){
72 const char* c_str() const {
73 return m_string.c_str();
75 void setString( const char* string ){
78 void evaluate( StringBuffer& output ){
79 StringBuffer variable;
80 bool in_variable = false;
81 for ( const char* i = m_string.c_str(); *i != '\0'; ++i )
90 output.push_back( *i );
100 output.push_string( build_get_variable( variable.c_str() ) );
104 variable.push_back( *i );
110 void exportXML( XMLImporter& importer ){
115 class Conditional : public Evaluatable
117 VariableString* m_test;
119 Evaluatable* m_result;
120 Conditional( VariableString* test ) : m_test( test ){
126 void evaluate( StringBuffer& output ){
128 m_test->evaluate( buffer );
129 if ( !string_empty( buffer.c_str() ) ) {
130 m_result->evaluate( output );
133 void exportXML( XMLImporter& importer ){
134 StaticElement conditionElement( "cond" );
135 conditionElement.insertAttribute( "value", m_test->c_str() );
136 importer.pushElement( conditionElement );
137 m_result->exportXML( importer );
138 importer.popElement( conditionElement.name() );
142 typedef std::vector<Evaluatable*> Evaluatables;
144 class Tool : public Evaluatable
146 Evaluatables m_evaluatables;
149 for ( Evaluatables::iterator i = m_evaluatables.begin(); i != m_evaluatables.end(); ++i )
154 void push_back( Evaluatable* evaluatable ){
155 m_evaluatables.push_back( evaluatable );
157 void evaluate( StringBuffer& output ){
158 for ( Evaluatables::iterator i = m_evaluatables.begin(); i != m_evaluatables.end(); ++i )
160 ( *i )->evaluate( output );
163 void exportXML( XMLImporter& importer ){
164 for ( Evaluatables::iterator i = m_evaluatables.begin(); i != m_evaluatables.end(); ++i )
166 ( *i )->exportXML( importer );
171 #include "xml/ixml.h"
173 class XMLElementParser : public TextOutputStream
176 virtual ~XMLElementParser() = default;
177 virtual XMLElementParser& pushElement( const XMLElement& element ) = 0;
178 virtual void popElement( const char* name ) = 0;
181 class VariableStringXMLConstructor : public XMLElementParser
183 StringBuffer m_buffer;
184 VariableString& m_variableString;
186 VariableStringXMLConstructor( VariableString& variableString ) : m_variableString( variableString ){
188 ~VariableStringXMLConstructor(){
189 m_variableString.setString( m_buffer.c_str() );
191 std::size_t write( const char* buffer, std::size_t length ){
192 m_buffer.push_range( buffer, buffer + length );
195 XMLElementParser& pushElement( const XMLElement& element ){
196 ERROR_MESSAGE( "parse error: invalid element \"" << element.name() << "\"" );
199 void popElement( const char* name ){
203 class ConditionalXMLConstructor : public XMLElementParser
205 StringBuffer m_buffer;
206 Conditional& m_conditional;
208 ConditionalXMLConstructor( Conditional& conditional ) : m_conditional( conditional ){
210 ~ConditionalXMLConstructor(){
211 m_conditional.m_result = new VariableString( m_buffer.c_str() );
213 std::size_t write( const char* buffer, std::size_t length ){
214 m_buffer.push_range( buffer, buffer + length );
217 XMLElementParser& pushElement( const XMLElement& element ){
218 ERROR_MESSAGE( "parse error: invalid element \"" << element.name() << "\"" );
221 void popElement( const char* name ){
225 class ToolXMLConstructor : public XMLElementParser
227 StringBuffer m_buffer;
229 ConditionalXMLConstructor* m_conditional;
231 ToolXMLConstructor( Tool& tool ) : m_tool( tool ){
233 ~ToolXMLConstructor(){
236 std::size_t write( const char* buffer, std::size_t length ){
237 m_buffer.push_range( buffer, buffer + length );
240 XMLElementParser& pushElement( const XMLElement& element ){
241 if ( string_equal( element.name(), "cond" ) ) {
243 Conditional* conditional = new Conditional( new VariableString( element.attribute( "value" ) ) );
244 m_tool.push_back( conditional );
245 m_conditional = new ConditionalXMLConstructor( *conditional );
246 return *m_conditional;
250 ERROR_MESSAGE( "parse error: invalid element \"" << element.name() << "\"" );
254 void popElement( const char* name ){
255 if ( string_equal( name, "cond" ) ) {
256 delete m_conditional;
261 if ( !m_buffer.empty() ) {
262 m_tool.push_back( new VariableString( m_buffer.c_str() ) );
268 typedef VariableString BuildCommand;
269 typedef std::list<BuildCommand> Build;
271 class BuildXMLConstructor : public XMLElementParser
273 VariableStringXMLConstructor* m_variableString;
276 BuildXMLConstructor( Build& build ) : m_build( build ){
278 std::size_t write( const char* buffer, std::size_t length ){
281 XMLElementParser& pushElement( const XMLElement& element ){
282 if ( string_equal( element.name(), "command" ) ) {
283 m_build.push_back( BuildCommand() );
284 m_variableString = new VariableStringXMLConstructor( m_build.back() );
285 return *m_variableString;
289 ERROR_MESSAGE( "parse error: invalid element" );
293 void popElement( const char* name ){
294 delete m_variableString;
298 typedef std::pair<CopiedString, Build> BuildPair;
299 const char *SEPARATOR_STRING = "-";
300 static bool is_separator( const BuildPair &p ){
301 if ( !string_equal( p.first.c_str(), SEPARATOR_STRING ) ) {
304 for ( Build::const_iterator j = p.second.begin(); j != p.second.end(); ++j )
306 if ( !string_equal( ( *j ).c_str(), "" ) ) {
314 typedef std::list<BuildPair> Project;
316 Project::iterator Project_find( Project& project, const char* name ){
317 return std::find_if(project.begin(), project.end(), [&](const BuildPair &self) {
318 return string_equal(self.first.c_str(), name);
322 Project::iterator Project_find( Project& project, std::size_t index ){
323 Project::iterator i = project.begin();
324 while ( index-- != 0 && i != project.end() )
331 Build& project_find( Project& project, const char* build ){
332 Project::iterator i = Project_find( project, build );
333 ASSERT_MESSAGE( i != project.end(), "error finding build command" );
334 return ( *i ).second;
337 Build::iterator Build_find( Build& build, std::size_t index ){
338 Build::iterator i = build.begin();
339 while ( index-- != 0 && i != build.end() )
346 typedef std::map<CopiedString, Tool> Tools;
348 class ProjectXMLConstructor : public XMLElementParser
350 ToolXMLConstructor* m_tool;
351 BuildXMLConstructor* m_build;
355 ProjectXMLConstructor( Project& project, Tools& tools ) : m_project( project ), m_tools( tools ){
357 std::size_t write( const char* buffer, std::size_t length ){
360 XMLElementParser& pushElement( const XMLElement& element ){
361 if ( string_equal( element.name(), "var" ) ) {
362 Tools::iterator i = m_tools.insert( Tools::value_type( element.attribute( "name" ), Tool() ) ).first;
363 m_tool = new ToolXMLConstructor( ( *i ).second );
366 else if ( string_equal( element.name(), "build" ) ) {
367 m_project.push_back( Project::value_type( element.attribute( "name" ), Build() ) );
368 m_build = new BuildXMLConstructor( m_project.back().second );
371 else if ( string_equal( element.name(), "separator" ) ) {
372 m_project.push_back( Project::value_type( SEPARATOR_STRING, Build() ) );
377 ERROR_MESSAGE( "parse error: invalid element" );
381 void popElement( const char* name ){
382 if ( string_equal( name, "var" ) ) {
385 else if ( string_equal( name, "build" ) ) {
391 class SkipAllParser : public XMLElementParser
394 std::size_t write( const char* buffer, std::size_t length ){
397 XMLElementParser& pushElement( const XMLElement& element ){
400 void popElement( const char* name ){
404 class RootXMLConstructor : public XMLElementParser
406 CopiedString m_elementName;
407 XMLElementParser& m_parser;
408 SkipAllParser m_skip;
412 RootXMLConstructor( const char* elementName, XMLElementParser& parser, const char* version ) :
413 m_elementName( elementName ),
415 m_version( version_parse( version ) ),
416 m_compatible( false ){
418 std::size_t write( const char* buffer, std::size_t length ){
421 XMLElementParser& pushElement( const XMLElement& element ){
422 if ( string_equal( element.name(), m_elementName.c_str() ) ) {
423 Version dataVersion( version_parse( element.attribute( "version" ) ) );
424 if ( version_compatible( m_version, dataVersion ) ) {
435 //ERROR_MESSAGE("parse error: invalid element \"" << element.name() << "\"");
439 void popElement( const char* name ){
442 bool versionCompatible() const {
449 Project g_build_project;
451 bool g_build_changed = false;
454 void build_error_undefined_tool( const char* build, const char* tool ){
455 globalErrorStream() << "build " << makeQuoted( build ) << " refers to undefined tool " << makeQuoted( tool ) << '\n';
458 void project_verify( Project& project, Tools& tools ){
460 for ( Project::iterator i = project.begin(); i != project.end(); ++i )
462 Build& build = ( *i ).second;
463 for ( Build::iterator j = build.begin(); j != build.end(); ++j )
465 Tools::iterator k = tools.find( ( *j ).first );
466 if ( k == g_build_tools.end() ) {
467 build_error_undefined_tool( ( *i ).first.c_str(), ( *j ).first.c_str() );
474 void build_run( const char* name, CommandListener& listener ){
475 for ( Tools::iterator i = g_build_tools.begin(); i != g_build_tools.end(); ++i )
478 ( *i ).second.evaluate( output );
479 build_set_variable( ( *i ).first.c_str(), output.c_str() );
483 Project::iterator i = Project_find( g_build_project, name );
484 if ( i != g_build_project.end() ) {
485 Build& build = ( *i ).second;
486 for ( Build::iterator j = build.begin(); j != build.end(); ++j )
489 ( *j ).evaluate( output );
490 listener.execute( output.c_str() );
495 globalErrorStream() << "build " << makeQuoted( name ) << " not defined";
501 typedef std::vector<XMLElementParser*> XMLElementStack;
503 class XMLParser : public XMLImporter
505 XMLElementStack m_stack;
507 XMLParser( XMLElementParser& parser ){
508 m_stack.push_back( &parser );
510 std::size_t write( const char* buffer, std::size_t length ){
511 return m_stack.back()->write( buffer, length );
513 void pushElement( const XMLElement& element ){
514 m_stack.push_back( &m_stack.back()->pushElement( element ) );
516 void popElement( const char* name ){
518 m_stack.back()->popElement( name );
522 #include "stream/textfilestream.h"
523 #include "xml/xmlparser.h"
525 const char* const BUILDMENU_VERSION = "2.0";
527 bool build_commands_parse( const char* filename ){
528 TextFileInputStream projectFile( filename );
529 if ( !projectFile.failed() ) {
530 ProjectXMLConstructor projectConstructor( g_build_project, g_build_tools );
531 RootXMLConstructor rootConstructor( "project", projectConstructor, BUILDMENU_VERSION );
532 XMLParser importer( rootConstructor );
533 XMLStreamParser parser( projectFile );
534 parser.exportXML( importer );
536 if ( rootConstructor.versionCompatible() ) {
537 project_verify( g_build_project, g_build_tools );
541 globalErrorStream() << "failed to parse build menu: " << makeQuoted( filename ) << "\n";
546 void build_commands_clear(){
547 g_build_project.clear();
548 g_build_tools.clear();
551 class BuildXMLExporter
555 BuildXMLExporter( Build& build ) : m_build( build ){
557 void exportXML( XMLImporter& importer ){
559 for ( Build::iterator i = m_build.begin(); i != m_build.end(); ++i )
561 StaticElement commandElement( "command" );
562 importer.pushElement( commandElement );
563 ( *i ).exportXML( importer );
564 importer.popElement( commandElement.name() );
570 class ProjectXMLExporter
575 ProjectXMLExporter( Project& project, Tools& tools ) : m_project( project ), m_tools( tools ){
577 void exportXML( XMLImporter& importer ){
578 StaticElement projectElement( "project" );
579 projectElement.insertAttribute( "version", BUILDMENU_VERSION );
580 importer.pushElement( projectElement );
583 for ( Tools::iterator i = m_tools.begin(); i != m_tools.end(); ++i )
585 StaticElement toolElement( "var" );
586 toolElement.insertAttribute( "name", ( *i ).first.c_str() );
587 importer.pushElement( toolElement );
588 ( *i ).second.exportXML( importer );
589 importer.popElement( toolElement.name() );
592 for ( Project::iterator i = m_project.begin(); i != m_project.end(); ++i )
594 if ( is_separator( *i ) ) {
595 StaticElement buildElement( "separator" );
596 importer.pushElement( buildElement );
597 importer.popElement( buildElement.name() );
602 StaticElement buildElement( "build" );
603 buildElement.insertAttribute( "name", ( *i ).first.c_str() );
604 importer.pushElement( buildElement );
605 BuildXMLExporter buildExporter( ( *i ).second );
606 buildExporter.exportXML( importer );
607 importer.popElement( buildElement.name() );
611 importer.popElement( projectElement.name() );
615 #include "xml/xmlwriter.h"
617 void build_commands_write( const char* filename ){
618 TextFileOutputStream projectFile( filename );
619 if ( !projectFile.failed() ) {
620 XMLStreamWriter writer( projectFile );
621 ProjectXMLExporter projectExporter( g_build_project, g_build_tools );
623 projectExporter.exportXML( writer );
629 #include <gdk/gdkkeysyms.h>
631 #include "gtkutil/dialog.h"
632 #include "gtkutil/closure.h"
633 #include "gtkutil/window.h"
636 void Build_refreshMenu( ui::Menu menu );
639 void BSPCommandList_Construct( ui::ListStore store, Project& project ){
642 for ( Project::iterator i = project.begin(); i != project.end(); ++i )
644 store.append(0, (*i).first.c_str());
654 ui::ListStore m_store{ui::null};
656 ProjectList( Project& project ) : m_project( project ), m_changed( false ){
660 gboolean project_cell_edited(ui::CellRendererText cell, gchar* path_string, gchar* new_text, ProjectList* projectList ){
661 Project& project = projectList->m_project;
663 auto path = ui::TreePath( path_string );
665 ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" );
668 gtk_tree_model_get_iter(projectList->m_store, &iter, path );
670 Project::iterator i = Project_find( project, gtk_tree_path_get_indices( path )[0] );
671 if ( i != project.end() ) {
672 projectList->m_changed = true;
673 if ( string_empty( new_text ) ) {
675 gtk_list_store_remove( projectList->m_store, &iter );
679 ( *i ).first = new_text;
680 gtk_list_store_set( projectList->m_store, &iter, 0, new_text, -1 );
683 else if ( !string_empty( new_text ) ) {
684 projectList->m_changed = true;
685 project.push_back( Project::value_type( new_text, Build() ) );
687 gtk_list_store_set( projectList->m_store, &iter, 0, new_text, -1 );
688 projectList->m_store.append();
691 gtk_tree_path_free( path );
693 Build_refreshMenu( g_bsp_menu );
698 gboolean project_key_press( ui::TreeView widget, GdkEventKey* event, ProjectList* projectList ){
699 Project& project = projectList->m_project;
701 if ( event->keyval == GDK_KEY_Delete ) {
702 auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(widget));
705 if ( gtk_tree_selection_get_selected( selection, &model, &iter ) ) {
706 auto path = gtk_tree_model_get_path( model, &iter );
707 Project::iterator x = Project_find( project, gtk_tree_path_get_indices( path )[0] );
708 gtk_tree_path_free( path );
710 if ( x != project.end() ) {
711 projectList->m_changed = true;
713 Build_refreshMenu( g_bsp_menu );
715 gtk_list_store_remove( projectList->m_store, &iter );
723 Build* g_current_build = 0;
725 gboolean project_selection_changed( ui::TreeSelection selection, ui::ListStore store ){
726 Project& project = g_build_project;
732 if ( gtk_tree_selection_get_selected( selection, &model, &iter ) ) {
733 auto path = gtk_tree_model_get_path( model, &iter );
734 Project::iterator x = Project_find( project, gtk_tree_path_get_indices( path )[0] );
735 gtk_tree_path_free( path );
737 if ( x != project.end() ) {
738 Build& build = ( *x ).second;
739 g_current_build = &build;
741 for ( Build::iterator i = build.begin(); i != build.end(); ++i )
743 store.append(0, (*i).c_str());
760 gboolean commands_cell_edited(ui::CellRendererText cell, gchar* path_string, gchar* new_text, ui::ListStore store ){
761 if ( g_current_build == 0 ) {
764 Build& build = *g_current_build;
766 auto path = ui::TreePath( path_string );
768 ASSERT_MESSAGE( gtk_tree_path_get_depth( path ) == 1, "invalid path length" );
771 gtk_tree_model_get_iter(store, &iter, path );
773 Build::iterator i = Build_find( build, gtk_tree_path_get_indices( path )[0] );
774 if ( i != build.end() ) {
775 g_build_changed = true;
776 ( *i ).setString( new_text );
778 gtk_list_store_set( store, &iter, 0, new_text, -1 );
780 else if ( !string_empty( new_text ) ) {
781 g_build_changed = true;
782 build.push_back( Build::value_type( VariableString( new_text ) ) );
784 gtk_list_store_set( store, &iter, 0, new_text, -1 );
789 gtk_tree_path_free( path );
791 Build_refreshMenu( g_bsp_menu );
796 gboolean commands_key_press( ui::TreeView widget, GdkEventKey* event, ui::ListStore store ){
797 if ( g_current_build == 0 ) {
800 Build& build = *g_current_build;
802 if ( event->keyval == GDK_KEY_Delete ) {
803 auto selection = gtk_tree_view_get_selection(widget );
806 if ( gtk_tree_selection_get_selected( selection, &model, &iter ) ) {
807 auto path = gtk_tree_model_get_path( model, &iter );
808 Build::iterator i = Build_find( build, gtk_tree_path_get_indices( path )[0] );
809 gtk_tree_path_free( path );
811 if ( i != build.end() ) {
812 g_build_changed = true;
815 gtk_list_store_remove( store, &iter );
823 ui::Window BuildMenuDialog_construct( ModalDialog& modal, ProjectList& projectList ){
824 ui::Window window = MainFrame_getWindow().create_dialog_window("Build Menu", G_CALLBACK(dialog_delete_callback ), &modal, -1, 400 );
827 auto table1 = create_dialog_table( 2, 2, 4, 4, 4 );
830 auto vbox = create_dialog_vbox( 4 );
831 table1.attach(vbox, {1, 2, 0, 1}, {GTK_FILL, GTK_FILL});
833 auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &modal );
834 vbox.pack_start( button, FALSE, FALSE, 0 );
837 auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &modal );
838 vbox.pack_start( button, FALSE, FALSE, 0 );
841 auto buildViewStore = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
842 auto buildView = ui::TreeView( ui::TreeModel::from( buildViewStore._handle ));
844 auto frame = create_dialog_frame( "Build menu" );
845 table1.attach(frame, {0, 1, 0, 1});
847 auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 );
851 auto view = buildView;
852 auto store = buildViewStore;
853 gtk_tree_view_set_headers_visible(view, FALSE );
855 auto renderer = ui::CellRendererText(ui::New);
856 object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE );
857 renderer.connect("edited", G_CALLBACK( project_cell_edited ), &projectList );
859 auto column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
860 gtk_tree_view_append_column(view, column );
862 auto selection = gtk_tree_view_get_selection(view );
863 gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE );
867 projectList.m_store = store;
870 view.connect( "key_press_event", G_CALLBACK( project_key_press ), &projectList );
877 auto frame = create_dialog_frame( "Commandline" );
878 table1.attach(frame, {0, 1, 1, 2});
880 auto scr = create_scrolled_window( ui::Policy::NEVER, ui::Policy::AUTOMATIC, 4 );
884 auto store = ui::ListStore::from(gtk_list_store_new( 1, G_TYPE_STRING ));
886 auto view = ui::TreeView(ui::TreeModel::from( store._handle ));
887 gtk_tree_view_set_headers_visible(view, FALSE );
889 auto renderer = ui::CellRendererText(ui::New);
890 object_set_boolean_property( G_OBJECT( renderer ), "editable", TRUE );
891 renderer.connect( "edited", G_CALLBACK( commands_cell_edited ), store );
893 auto column = ui::TreeViewColumn( "", renderer, {{"text", 0}} );
894 gtk_tree_view_append_column(view, column );
896 auto selection = gtk_tree_view_get_selection(view );
897 gtk_tree_selection_set_mode( selection, GTK_SELECTION_BROWSE );
905 view.connect( "key_press_event", G_CALLBACK( commands_key_press ), store );
907 auto sel = ui::TreeSelection::from(gtk_tree_view_get_selection(buildView ));
908 sel.connect( "changed", G_CALLBACK( project_selection_changed ), store );
914 BSPCommandList_Construct( projectList.m_store, g_build_project );
921 CopiedString g_buildMenu;
924 void LoadBuildMenu();
929 ProjectList projectList( g_build_project );
931 ui::Window window = BuildMenuDialog_construct( modal, projectList );
933 if ( modal_dialog_show( window, modal ) == eIDCANCEL ) {
934 build_commands_clear();
937 Build_refreshMenu( g_bsp_menu );
939 else if ( projectList.m_changed ) {
940 g_build_changed = true;
948 #include "gtkutil/menu.h"
949 #include "mainframe.h"
950 #include "preferences.h"
958 BuildMenuItem( const char* name, ui::MenuItem item )
959 : m_name( name ), m_item( item ){
964 typedef MemberCaller<BuildMenuItem, void(), &BuildMenuItem::run> RunCaller;
967 typedef std::list<BuildMenuItem> BuildMenuItems;
968 BuildMenuItems g_BuildMenuItems;
971 ui::Menu g_bsp_menu{ui::null};
973 void Build_constructMenu( ui::Menu menu ){
974 for ( Project::iterator i = g_build_project.begin(); i != g_build_project.end(); ++i )
976 g_BuildMenuItems.push_back( BuildMenuItem( ( *i ).first.c_str(), ui::MenuItem(ui::null) ) );
977 if ( is_separator( *i ) ) {
978 g_BuildMenuItems.back().m_item = menu_separator( menu );
982 g_BuildMenuItems.back().m_item = create_menu_item_with_mnemonic( menu, ( *i ).first.c_str(), BuildMenuItem::RunCaller( g_BuildMenuItems.back() ) );
988 void Build_refreshMenu( ui::Menu menu ){
989 for (auto i = g_BuildMenuItems.begin(); i != g_BuildMenuItems.end(); ++i )
991 menu.remove(ui::MenuItem(i->m_item));
994 g_BuildMenuItems.clear();
996 Build_constructMenu( menu );
1000 void LoadBuildMenu(){
1001 if ( string_empty( g_buildMenu.c_str() ) || !build_commands_parse( g_buildMenu.c_str() ) ) {
1003 StringOutputStream buffer( 256 );
1004 buffer << GameToolsPath_get() << "default_build_menu.xml";
1006 bool success = build_commands_parse( buffer.c_str() );
1007 ASSERT_MESSAGE( success, "failed to parse default build commands: " << buffer.c_str() );
1010 StringOutputStream buffer( 256 );
1011 buffer << SettingsPath_get() << g_pGameDescription->mGameFile.c_str() << "/build_menu.xml";
1013 g_buildMenu = buffer.c_str();
1018 void SaveBuildMenu(){
1019 if ( g_build_changed ) {
1020 g_build_changed = false;
1021 build_commands_write( g_buildMenu.c_str() );
1025 #include "preferencesystem.h"
1026 #include "stringio.h"
1028 void BuildMenu_Construct(){
1029 GlobalPreferenceSystem().registerPreference( "BuildMenu", make_property_string( g_buildMenu ) );
1032 void BuildMenu_Destroy(){