#include "select.h"
#include "map.h"
#include "preferences.h"
+#include "preferencesystem.h"
+#include "stringio.h"
#include "gtkdlgs.h"
#include "mainframe.h"
#include "qe3.h"
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
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
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() ) {
}
-
void Entity_connectSelected(){
if ( GlobalSelectionSystem().countSelected() == 2 ) {
GlobalEntityCreator().connectEntities(
void Entity_createFromSelection( const char* name, const Vector3& origin ){
#if 0
if ( string_equal_nocase( name, "worldspawn" ) ) {
- ui::alert( GTK_WIDGET( MainFrame_getWindow() ), "Can't create an entity with worldspawn.", "info" );
+ ui::alert( MainFrame_getWindow( ), "Can't create an entity with worldspawn.", "info" );
return;
}
#endif
#if 0
bool DoNormalisedColor( Vector3& color ){
- if ( !color_dialog( GTK_WIDGET( MainFrame_getWindow() ), color ) ) {
+ if ( !color_dialog( MainFrame_getWindow( ), color ) ) {
return false;
}
/*
}
}
-const char* misc_model_dialog( ui::Widget parent ){
- StringOutputStream buffer( 1024 );
+CopiedString g_strLastModelFolder = "";
- 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() << "/";
+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";
}
return 0;
}
-void LightRadiiImport( EntityCreator& self, bool value ){
- self.setLightRadii( value );
-}
-typedef ReferenceCaller1<EntityCreator, bool, LightRadiiImport> LightRadiiImportCaller;
+struct LightRadii {
+ static void Export(const EntityCreator &self, const Callback<void(bool)> &returnz) {
+ returnz(self.getLightRadii());
+ }
-void LightRadiiExport( EntityCreator& self, const BoolImportCallback& importer ){
- importer( self.getLightRadii() );
-}
-typedef ReferenceCaller1<EntityCreator, const BoolImportCallback&, LightRadiiExport> LightRadiiExportCaller;
+ static void Import(EntityCreator &self, bool value) {
+ self.setLightRadii(value);
+ }
+};
void Entity_constructPreferences( PreferencesPage& page ){
page.appendCheckBox(
- "Show", "Light Radii",
- LightRadiiImportCaller( GlobalEntityCreator() ),
- LightRadiiExportCaller( GlobalEntityCreator() )
- );
+ "Show", "Light Radii",
+ make_property<LightRadii>(GlobalEntityCreator())
+ );
}
void Entity_constructPage( PreferenceGroup& group ){
PreferencesPage page( group.createPage( "Entities", "Entity Display Preferences" ) );
Entity_constructPreferences( page );
}
+
void Entity_registerPreferencesPage(){
- PreferencesDialog_addDisplayPage( FreeCaller1<PreferenceGroup&, Entity_constructPage>() );
+ PreferencesDialog_addDisplayPage( makeCallbackF(Entity_constructPage) );
}
-
-void Entity_constructMenu( GtkMenu* menu ){
+void Entity_constructMenu( ui::Menu menu ){
create_menu_item_with_mnemonic( menu, "_Regroup", "GroupSelection" );
create_menu_item_with_mnemonic( menu, "_Ungroup", "UngroupSelection" );
create_menu_item_with_mnemonic( menu, "_Connect", "ConnectSelection" );
}
-
-#include "preferencesystem.h"
-#include "stringio.h"
-
void Entity_Construct(){
- GlobalCommands_insert( "EntityColor", FreeCaller<Entity_setColour>(), Accelerator( 'K' ) );
- GlobalCommands_insert( "NormalizeColor", FreeCaller<Entity_normalizeColor>() );
- GlobalCommands_insert( "ConnectSelection", FreeCaller<Entity_connectSelected>(), Accelerator( 'K', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "KillConnectSelection", FreeCaller<Entity_killconnectSelected>(), Accelerator( 'K', (GdkModifierType)( GDK_SHIFT_MASK ) ) );
- GlobalCommands_insert( "GroupSelection", FreeCaller<Entity_groupSelected>() );
- GlobalCommands_insert( "UngroupSelection", FreeCaller<Entity_ungroupSelected>() );
-
- GlobalPreferenceSystem().registerPreference( "SI_Colors5", Vector3ImportStringCaller( g_entity_globals.color_entity ), Vector3ExportStringCaller( g_entity_globals.color_entity ) );
- GlobalPreferenceSystem().registerPreference( "LastLightIntensity", IntImportStringCaller( g_iLastLightIntensity ), IntExportStringCaller( g_iLastLightIntensity ) );
+ GlobalCommands_insert( "EntityColor", makeCallbackF(Entity_setColour), Accelerator( 'K' ) );
+ GlobalCommands_insert( "NormalizeColor", makeCallbackF(Entity_normalizeColor) );
+ GlobalCommands_insert( "ConnectSelection", makeCallbackF(Entity_connectSelected), Accelerator( 'K', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "KillConnectSelection", makeCallbackF(Entity_killconnectSelected), Accelerator( 'K', (GdkModifierType)( GDK_SHIFT_MASK ) ) );
+ GlobalCommands_insert( "GroupSelection", makeCallbackF(Entity_groupSelected) );
+ GlobalCommands_insert( "UngroupSelection", makeCallbackF(Entity_ungroupSelected) );
+
+ GlobalPreferenceSystem().registerPreference( "SI_Colors5", make_property_string( g_entity_globals.color_entity ) );
+ GlobalPreferenceSystem().registerPreference( "LastLightIntensity", make_property_string( g_iLastLightIntensity ) );
Entity_registerPreferencesPage();
}