#include "url.h"
#include "cmdlib.h"
+#include "qerplugin.h"
+#include "os/file.h"
+
// =============================================================================
}
void DoProjectSettings(){
- if ( ConfirmModified( "Edit Project Settings" ) ) {
+ //if ( ConfirmModified( "Edit Project Settings" ) ) {
ModalDialog modal;
ProjectSettingsDialog dialog;
}
gtk_widget_destroy( GTK_WIDGET( window ) );
- }
+ //}
}
// =============================================================================
GtkFrame* frame = create_dialog_frame( 0, GTK_SHADOW_IN );
gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), FALSE, FALSE, 0 );
{
- GtkImage* image = new_local_image( "logo.bmp" );
+ GtkImage* image = new_local_image( "logo.png" );
gtk_widget_show( GTK_WIDGET( image ) );
gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( image ) );
}
RADIANT_ABOUTMSG "\n\n"
"By alientrap.org\n\n"
"This program is free software\n"
- "licensed under the GNU GPL.\n\n"
- "NetRadiant is unsupported, however\n"
- "you may report your problems at\n"
- "http://www.icculus.org/netradiant/"
+ "licensed under the GNU GPL.\n"
) );
gtk_widget_show( GTK_WIDGET( label ) );
}
}
}
-
+
// Initialize with last used values
char buf[16];
-
+
sprintf( buf, "%f", last_used_texture_layout_scale_x );
gtk_entry_set_text( x, buf );
-
+
sprintf( buf, "%f", last_used_texture_layout_scale_y );
gtk_entry_set_text( y, buf );
if ( ret == eIDOK ) {
*fx = static_cast<float>( atof( gtk_entry_get_text( x ) ) );
*fy = static_cast<float>( atof( gtk_entry_get_text( y ) ) );
-
+
// Remember last used values
last_used_texture_layout_scale_x = *fx;
last_used_texture_layout_scale_y = *fy;
// master window widget
static GtkWidget *text_editor = 0;
static GtkWidget *text_widget; // slave, text widget from the gtk editor
+static GtkTextBuffer* text_buffer_;
static gint editor_delete( GtkWidget *widget, gpointer data ){
- if ( gtk_MessageBox( widget, "Close the shader editor ?", "Radiant", eMB_YESNO, eMB_ICONQUESTION ) == eIDNO ) {
+/* if ( gtk_MessageBox( widget, "Close the shader editor ?", "Radiant", eMB_YESNO, eMB_ICONQUESTION ) == eIDNO ) {
return TRUE;
}
-
+*/
gtk_widget_hide( text_editor );
return TRUE;
static void editor_save( GtkWidget *widget, gpointer data ){
FILE *f = fopen( (char*)g_object_get_data( G_OBJECT( data ), "filename" ), "w" );
- gpointer text = g_object_get_data( G_OBJECT( data ), "text" );
+ //gpointer text = g_object_get_data( G_OBJECT( data ), "text" );
if ( f == 0 ) {
gtk_MessageBox( GTK_WIDGET( data ), "Error saving file !" );
return;
}
- char *str = gtk_editable_get_chars( GTK_EDITABLE( text ), 0, -1 );
+ /* Obtain iters for the start and end of points of the buffer */
+ GtkTextIter start;
+ GtkTextIter end;
+ gtk_text_buffer_get_start_iter (text_buffer_, &start);
+ gtk_text_buffer_get_end_iter (text_buffer_, &end);
+
+ /* Get the entire buffer text. */
+ char *str = gtk_text_buffer_get_text (text_buffer_, &start, &end, FALSE);
+
+ //char *str = gtk_editable_get_chars( GTK_EDITABLE( text ), 0, -1 );
fwrite( str, 1, strlen( str ), f );
fclose( f );
+ g_free (str);
}
static void editor_close( GtkWidget *widget, gpointer data ){
- if ( gtk_MessageBox( text_editor, "Close the shader editor ?", "Radiant", eMB_YESNO, eMB_ICONQUESTION ) == eIDNO ) {
+/* if ( gtk_MessageBox( text_editor, "Close the shader editor ?", "Radiant", eMB_YESNO, eMB_ICONQUESTION ) == eIDNO ) {
return;
}
-
+*/
gtk_widget_hide( text_editor );
}
g_signal_connect( G_OBJECT( dlg ), "delete_event",
G_CALLBACK( editor_delete ), 0 );
- gtk_window_set_default_size( GTK_WINDOW( dlg ), 600, 300 );
+ gtk_window_set_default_size( GTK_WINDOW( dlg ), 400, 600 );
vbox = gtk_vbox_new( FALSE, 5 );
gtk_widget_show( vbox );
text_widget = text;
}
-static void DoGtkTextEditor( const char* filename, guint cursorpos ){
+static void DoGtkTextEditor( const char* filename, guint cursorpos, int length ){
if ( !text_editor ) {
CreateGtkTextEditor(); // build it the first time we need it
gtk_window_set_title( GTK_WINDOW( text_editor ), filename );
GtkTextBuffer* text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( text_widget ) );
- gtk_text_buffer_set_text( text_buffer, (char*)buf, len );
+ gtk_text_buffer_set_text( text_buffer, (char*)buf, length );
old_filename = g_object_get_data( G_OBJECT( text_editor ), "filename" );
if ( old_filename ) {
// character offset, not byte offset
gtk_text_buffer_get_iter_at_offset( text_buffer, &text_iter, cursorpos );
gtk_text_buffer_place_cursor( text_buffer, &text_iter );
+ gtk_text_view_scroll_to_iter( GTK_TEXT_VIEW( text_widget ), &text_iter, 0, TRUE, 0, 0);
}
#ifdef WIN32
gtk_widget_queue_draw( text_widget );
#endif
+ text_buffer_ = text_buffer;
free( buf );
fclose( f );
}
#ifdef WIN32
// use the file associations to open files instead of builtin Gtk editor
-bool g_TextEditor_useWin32Editor = true;
+bool g_TextEditor_useWin32Editor = false;
#else
// custom shader editor
bool g_TextEditor_useCustomEditor = false;
CopiedString g_TextEditor_editorCommand( "" );
#endif
-void DoTextEditor( const char* filename, int cursorpos ){
+void DoTextEditor( const char* filename, int cursorpos, int length ){
#ifdef WIN32
if ( g_TextEditor_useWin32Editor ) {
- globalOutputStream() << "opening file '" << filename << "' (line " << cursorpos << " info ignored)\n";
- ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", filename, 0, 0, SW_SHOW );
+ StringOutputStream path( 256 );
+ StringOutputStream modpath( 256 );
+ const char* gamename = GlobalRadiant().getGameName();
+ const char* basegame = GlobalRadiant().getRequiredGameDescriptionKeyValue( "basegame" );
+ const char* enginePath = GlobalRadiant().getEnginePath();
+ path << enginePath << basegame << '/' << filename;
+ modpath << enginePath << gamename << '/' << filename;
+ if ( file_exists( modpath.c_str() ) ){
+ globalOutputStream() << "opening file '" << modpath.c_str() << "' (line " << cursorpos << " info ignored)\n";
+ ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", modpath.c_str(), 0, 0, SW_SHOW );
+ }
+ else if ( file_exists( path.c_str() ) ){
+ globalOutputStream() << "opening file '" << path.c_str() << "' (line " << cursorpos << " info ignored)\n";
+ ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", path.c_str(), 0, 0, SW_SHOW );
+ }
+ else{
+ globalOutputStream() << "Failed to open '" << filename << "\n";
+ }
+ return;
+ }
+ else{
+ StringOutputStream path( 256 );
+ StringOutputStream modpath( 256 );
+ const char* gamename = GlobalRadiant().getGameName();
+ const char* basegame = GlobalRadiant().getRequiredGameDescriptionKeyValue( "basegame" );
+ const char* enginePath = GlobalRadiant().getEnginePath();
+ path << enginePath << basegame << '/' << filename;
+ modpath << enginePath << gamename << '/' << filename;
+ if ( file_exists( modpath.c_str() ) ){
+ globalOutputStream() << "opening file '" << modpath.c_str() << "' (line " << cursorpos << " info ignored)\n";
+ DoGtkTextEditor( modpath.c_str(), cursorpos, length );
+ }
+ else if ( file_exists( path.c_str() ) ){
+ globalOutputStream() << "opening file '" << path.c_str() << "' (line " << cursorpos << " info ignored)\n";
+ DoGtkTextEditor( path.c_str(), cursorpos, length );
+ }
+ else{
+ globalOutputStream() << "Failed to open '" << filename << "\n";
+ }
return;
}
#else
return;
}
}
-#endif
- DoGtkTextEditor( filename, cursorpos );
+ DoGtkTextEditor( filename, cursorpos, length );
+#endif
}