X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fentity.cpp;h=adb4ed11089aaebc74a47b33d10137b1301df8f3;hb=b2ef6fd57c04a96bf457fee71e3b1a0e4c60d256;hp=2952684df04ee93645c1fafdb4da6d8261f5f7c9;hpb=fea0d2e6575b21945c4800805d66e43a2247ded5;p=xonotic%2Fnetradiant.git diff --git a/radiant/entity.cpp b/radiant/entity.cpp index 2952684d..adb4ed11 100644 --- a/radiant/entity.cpp +++ b/radiant/entity.cpp @@ -40,6 +40,8 @@ #include "select.h" #include "map.h" #include "preferences.h" +#include "preferencesystem.h" +#include "stringio.h" #include "gtkdlgs.h" #include "mainframe.h" #include "qe3.h" @@ -66,9 +68,11 @@ public: EntitySetKeyValueSelected( const char* key, const char* value ) : m_key( key ), m_value( value ){ } + bool pre( const scene::Path& path, scene::Instance& instance ) const { return true; } + void post( const scene::Path& path, scene::Instance& instance ) const { Entity* entity = Node_getEntity( path.top() ); if ( entity != 0 @@ -152,11 +156,14 @@ class EntityFindSelected : public scene::Graph::Walker public: mutable const scene::Path *groupPath; mutable scene::Instance *groupInstance; + EntityFindSelected() : groupPath( 0 ), groupInstance( 0 ){ } + bool pre( const scene::Path& path, scene::Instance& instance ) const { return true; } + void post( const scene::Path& path, scene::Instance& instance ) const { Entity* entity = Node_getEntity( path.top() ); if ( entity != 0 @@ -177,9 +184,11 @@ NodeSmartReference group, worldspawn; public: EntityGroupSelected( const scene::Path &p ) : group( p.top().get() ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){ } + bool pre( const scene::Path& path, scene::Instance& instance ) const { return true; } + void post( const scene::Path& path, scene::Instance& instance ) const { Selectable *selectable = Instance_getSelectable( instance ); if ( selectable && selectable->isSelected() ) { @@ -231,7 +240,6 @@ void Entity_groupSelected(){ } - void Entity_connectSelected(){ if ( GlobalSelectionSystem().countSelected() == 2 ) { GlobalEntityCreator().connectEntities( @@ -519,21 +527,32 @@ void Entity_setColour(){ } } -const char* misc_model_dialog( ui::Widget parent ){ - StringOutputStream buffer( 1024 ); - - buffer << g_qeglobals.m_userGamePath.c_str() << "models/"; - - if ( !file_readable( buffer.c_str() ) ) { - // just go to fsmain - buffer.clear(); - buffer << g_qeglobals.m_userGamePath.c_str() << "/"; +CopiedString g_strLastModelFolder = ""; + +const char *getLastModelFolderPath(){ + if ( g_strLastModelFolder.empty() ) { + GlobalPreferenceSystem().registerPreference( "LastModelFolder", make_property_string( g_strLastModelFolder ) ); + if ( g_strLastModelFolder.empty() ) { + StringOutputStream buffer( 1024 ); + buffer << g_qeglobals.m_userGamePath.c_str() << "models/"; + if ( !file_readable( buffer.c_str() ) ) { + // just go to fsmain + buffer.clear(); + buffer << g_qeglobals.m_userGamePath.c_str() << "/"; + } + g_strLastModelFolder = buffer.c_str(); + } } + return g_strLastModelFolder.c_str(); +} + +const char *misc_model_dialog( ui::Widget parent ){ + const char *filename = parent.file_dialog( TRUE, "Choose Model", getLastModelFolderPath(), ModelLoader::Name() ); - const char *filename = parent.file_dialog( TRUE, "Choose Model", buffer.c_str(), ModelLoader::Name() ); - if ( filename != 0 ) { + if ( filename != NULL ) { + g_strLastModelFolder = g_path_get_dirname( filename ); // use VFS to get the correct relative path - const char* relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) ); + const char *relative = path_make_relative( filename, GlobalFileSystem().findRoot( filename ) ); if ( relative == filename ) { globalOutputStream() << "WARNING: could not extract the relative path, using full path instead\n"; } @@ -562,12 +581,12 @@ void Entity_constructPage( PreferenceGroup& group ){ PreferencesPage page( group.createPage( "Entities", "Entity Display Preferences" ) ); Entity_constructPreferences( page ); } + void Entity_registerPreferencesPage(){ PreferencesDialog_addDisplayPage( makeCallbackF(Entity_constructPage) ); } - void Entity_constructMenu( ui::Menu menu ){ create_menu_item_with_mnemonic( menu, "_Regroup", "GroupSelection" ); create_menu_item_with_mnemonic( menu, "_Ungroup", "UngroupSelection" ); @@ -578,10 +597,6 @@ void Entity_constructMenu( ui::Menu menu ){ } - -#include "preferencesystem.h" -#include "stringio.h" - void Entity_Construct(){ GlobalCommands_insert( "EntityColor", makeCallbackF(Entity_setColour), Accelerator( 'K' ) ); GlobalCommands_insert( "NormalizeColor", makeCallbackF(Entity_normalizeColor) );