char value[64];
if ( angles[0] == 0 && angles[1] == 0 ) {
+ float yaw = angles[2];
entity->setKeyValue( "angles", "" );
- write_angle( angles[2], entity );
+ write_angle( yaw, entity );
}
else
{
class AnglesKey
{
-Callback m_anglesChanged;
+Callback<void()> m_anglesChanged;
public:
Vector3 m_angles;
-AnglesKey( const Callback& anglesChanged )
+AnglesKey( const Callback<void()>& anglesChanged )
: m_anglesChanged( anglesChanged ), m_angles( ANGLESKEY_IDENTITY ){
}
read_angle( m_angles, value );
m_anglesChanged();
}
-typedef MemberCaller1<AnglesKey, const char*, &AnglesKey::angleChanged> AngleChangedCaller;
+typedef MemberCaller<AnglesKey, void(const char*), &AnglesKey::angleChanged> AngleChangedCaller;
void anglesChanged( const char* value ){
read_angles( m_angles, value );
m_anglesChanged();
}
-typedef MemberCaller1<AnglesKey, const char*, &AnglesKey::anglesChanged> AnglesChangedCaller;
+typedef MemberCaller<AnglesKey, void(const char*), &AnglesKey::anglesChanged> AnglesChangedCaller;
void write( Entity* entity ) const {
write_angles( m_angles, entity );
//
#include "gtkdlgs.h"
+#include "globaldefs.h"
+
+#include <gtk/gtk.h>
#include "debugging/debugging.h"
#include "version.h"
#include "iselection.h"
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkmain.h>
-#include <gtk/gtkentry.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtktable.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtkcombobox.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktextview.h>
-#include <gtk/gtktextbuffer.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtkliststore.h>
+#include <uilib/uilib.h>
#include "os/path.h"
#include "math/aabb.h"
#include "url.h"
#include "cmdlib.h"
+ #include "qerplugin.h"
+ #include "os/file.h"
+
// =============================================================================
struct GameCombo
{
- GtkComboBox* game_select;
- GtkEntry* fsgame_entry;
+ ui::ComboBoxText game_select{ui::null};
+ ui::Entry fsgame_entry{ui::null};
};
-gboolean OnSelchangeComboWhatgame( GtkWidget *widget, GameCombo* combo ){
+gboolean OnSelchangeComboWhatgame( ui::Widget widget, GameCombo* combo ){
const char *gamename;
{
GtkTreeIter iter;
gamecombo_t gamecombo = gamecombo_for_gamename( gamename );
- gtk_entry_set_text( combo->fsgame_entry, gamecombo.fs_game );
- gtk_widget_set_sensitive( GTK_WIDGET( combo->fsgame_entry ), gamecombo.sensitive );
+ combo->fsgame_entry.text( gamecombo.fs_game );
+ gtk_widget_set_sensitive( combo->fsgame_entry , gamecombo.sensitive );
return FALSE;
}
{
public:
GameCombo game_combo;
-GtkComboBox* gamemode_combo;
+ui::ComboBox gamemode_combo{ui::null};
};
-GtkWindow* ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, ModalDialog& modal ){
- GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Project Settings", G_CALLBACK( dialog_delete_callback ), &modal );
+ui::Window ProjectSettingsDialog_construct( ProjectSettingsDialog& dialog, ModalDialog& modal ){
+ auto window = MainFrame_getWindow().create_dialog_window("Project Settings", G_CALLBACK(dialog_delete_callback ), &modal );
{
- GtkTable* table1 = create_dialog_table( 1, 2, 4, 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( table1 ) );
+ auto table1 = create_dialog_table( 1, 2, 4, 4, 4 );
+ window.add(table1);
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_table_attach( table1, GTK_WIDGET( vbox ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ table1.attach(vbox, {1, 2, 0, 1}, {GTK_FILL, GTK_FILL});
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &modal );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &modal );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &modal );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &modal );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
}
}
{
- GtkFrame* frame = create_dialog_frame( "Project settings" );
- gtk_table_attach( table1, GTK_WIDGET( frame ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( GTK_FILL ), 0, 0 );
+ auto frame = create_dialog_frame( "Project settings" );
+ table1.attach(frame, {0, 1, 0, 1}, {GTK_EXPAND | GTK_FILL, GTK_FILL});
{
- GtkTable* table2 = create_dialog_table( ( globalMappingMode().do_mapping_mode ) ? 4 : 3, 2, 4, 4, 4 );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( table2 ) );
+ auto table2 = create_dialog_table( ( globalMappingMode().do_mapping_mode ) ? 4 : 3, 2, 4, 4, 4 );
+ frame.add(table2);
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Select mod" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Select mod" );
+ label.show();
+ table2.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
}
{
- dialog.game_combo.game_select = GTK_COMBO_BOX( gtk_combo_box_new_text() );
+ dialog.game_combo.game_select = ui::ComboBoxText(ui::New);
- gtk_combo_box_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().basegame );
+ gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().basegame );
if ( globalGameComboConfiguration().known[0] != '\0' ) {
- gtk_combo_box_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().known );
+ gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().known );
}
- gtk_combo_box_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().custom );
+ gtk_combo_box_text_append_text( dialog.game_combo.game_select, globalGameComboConfiguration().custom );
- gtk_widget_show( GTK_WIDGET( dialog.game_combo.game_select ) );
- gtk_table_attach( table2, GTK_WIDGET( dialog.game_combo.game_select ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ dialog.game_combo.game_select.show();
+ table2.attach(dialog.game_combo.game_select, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
- g_signal_connect( G_OBJECT( dialog.game_combo.game_select ), "changed", G_CALLBACK( OnSelchangeComboWhatgame ), &dialog.game_combo );
+ dialog.game_combo.game_select.connect( "changed", G_CALLBACK( OnSelchangeComboWhatgame ), &dialog.game_combo );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "fs_game" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "fs_game" );
+ label.show();
+ table2.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table2, GTK_WIDGET( entry ), 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table2.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
dialog.game_combo.fsgame_entry = entry;
}
if ( globalMappingMode().do_mapping_mode ) {
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Mapping mode" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table2, GTK_WIDGET( label ), 0, 1, 3, 4,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Mapping mode" );
+ label.show();
+ table2.attach(label, {0, 1, 3, 4}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
- GtkComboBox* combo = GTK_COMBO_BOX( gtk_combo_box_new_text() );
- gtk_combo_box_append_text( combo, globalMappingMode().sp_mapping_mode );
- gtk_combo_box_append_text( combo, globalMappingMode().mp_mapping_mode );
+ auto combo = ui::ComboBoxText(ui::New);
+ gtk_combo_box_text_append_text( combo, globalMappingMode().sp_mapping_mode );
+ gtk_combo_box_text_append_text( combo, globalMappingMode().mp_mapping_mode );
- gtk_widget_show( GTK_WIDGET( combo ) );
- gtk_table_attach( table2, GTK_WIDGET( combo ), 1, 2, 3, 4,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ combo.show();
+ table2.attach(combo, {1, 2, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
dialog.gamemode_combo = combo;
}
gamecombo_t gamecombo = gamecombo_for_dir( dir );
gtk_combo_box_set_active( dialog.game_combo.game_select, gamecombo.game );
- gtk_entry_set_text( dialog.game_combo.fsgame_entry, gamecombo.fs_game );
- gtk_widget_set_sensitive( GTK_WIDGET( dialog.game_combo.fsgame_entry ), gamecombo.sensitive );
+ dialog.game_combo.fsgame_entry.text( gamecombo.fs_game );
+ gtk_widget_set_sensitive( dialog.game_combo.fsgame_entry , gamecombo.sensitive );
if ( globalMappingMode().do_mapping_mode ) {
const char *gamemode = gamemode_get();
ModalDialog modal;
ProjectSettingsDialog dialog;
- GtkWindow* window = ProjectSettingsDialog_construct( dialog, modal );
+ ui::Window window = ProjectSettingsDialog_construct( dialog, modal );
if ( modal_dialog_show( window, modal ) == eIDOK ) {
ProjectSettingsDialog_ok( dialog );
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
//}
}
void DoSides( int type, int axis ){
ModalDialog dialog;
- GtkEntry* sides_entry;
- GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Arbitrary sides", G_CALLBACK( dialog_delete_callback ), &dialog );
+ auto window = MainFrame_getWindow().create_dialog_window("Arbitrary sides", G_CALLBACK(dialog_delete_callback ), &dialog );
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel );
+ auto accel = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel );
+ auto sides_entry = ui::Entry(ui::New);
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Sides:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( "Sides:" );
+ label.show();
+ hbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( entry ), FALSE, FALSE, 0 );
- sides_entry = entry;
- gtk_widget_grab_focus( GTK_WIDGET( entry ) );
+ auto entry = sides_entry;
+ entry.show();
+ hbox.pack_start( entry, FALSE, FALSE, 0 );
+ gtk_widget_grab_focus( entry );
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
}
}
Scene_BrushConstructPrefab( GlobalSceneGraph(), (EBrushPrefab)type, atoi( str ), TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ) );
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
}
// =============================================================================
// About dialog (no program is complete without one)
-void about_button_changelog( GtkWidget *widget, gpointer data ){
+void about_button_changelog( ui::Widget widget, gpointer data ){
StringOutputStream log( 256 );
- log << AppPath_get() << "changelog.txt";
+ log << "https://gitlab.com/xonotic/netradiant/commits/master";
OpenURL( log.c_str() );
}
-void about_button_credits( GtkWidget *widget, gpointer data ){
+void about_button_credits( ui::Widget widget, gpointer data ){
+ StringOutputStream cred( 256 );
+ cred << "https://gitlab.com/xonotic/netradiant/graphs/master";
+ OpenURL( cred.c_str() );
+}
+
+void about_button_issues( ui::Widget widget, gpointer data ){
StringOutputStream cred( 256 );
- cred << AppPath_get() << "credits.html";
+ cred << "https://gitlab.com/xonotic/netradiant/issues";
OpenURL( cred.c_str() );
}
ModalDialog dialog;
ModalDialogButton ok_button( dialog, eIDOK );
- GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "About NetRadiant", dialog );
+ auto window = MainFrame_getWindow().create_modal_dialog_window("About NetRadiant", dialog );
{
- GtkVBox* vbox = create_dialog_vbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox ) );
+ auto vbox = create_dialog_vbox( 4, 4 );
+ window.add(vbox);
{
- GtkHBox* hbox = create_dialog_hbox( 4 );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, TRUE, 0 );
+ auto hbox = create_dialog_hbox( 4 );
+ vbox.pack_start( hbox, FALSE, TRUE, 0 );
{
- GtkVBox* vbox2 = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), TRUE, FALSE, 0 );
+ auto vbox2 = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox2, TRUE, FALSE, 0 );
{
- GtkFrame* frame = create_dialog_frame( 0, GTK_SHADOW_IN );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( frame ), FALSE, FALSE, 0 );
+ auto frame = create_dialog_frame( 0, ui::Shadow::IN );
+ vbox2.pack_start( frame, FALSE, FALSE, 0 );
{
- GtkImage* image = new_local_image( "logo.bmp" );
- gtk_widget_show( GTK_WIDGET( image ) );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( image ) );
+ auto image = new_local_image( "logo.png" );
+ image.show();
+ frame.add(image);
}
}
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "NetRadiant " RADIANT_VERSION "\n"
- __DATE__ "\n\n"
- RADIANT_ABOUTMSG "\n\n"
- "By alientrap.org\n\n"
- "This program is free software\n"
- "licensed under the GNU GPL.\n"
- ) );
-
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ char const *label_text = "NetRadiant " RADIANT_VERSION "\n"
+ __DATE__ "\n\n"
+ RADIANT_ABOUTMSG "\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"
+ "https://gitlab.com/xonotic/netradiant/issues";
+
+ auto label = ui::Label( label_text );
+
+ label.show();
+ hbox.pack_start( label, FALSE, FALSE, 0 );
gtk_misc_set_alignment( GTK_MISC( label ), 1, 0.5 );
gtk_label_set_justify( label, GTK_JUSTIFY_LEFT );
}
{
- GtkVBox* vbox2 = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox2 ), FALSE, TRUE, 0 );
+ auto vbox2 = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox2, FALSE, TRUE, 0 );
{
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ vbox2.pack_start( button, FALSE, FALSE, 0 );
}
{
- GtkButton* button = create_dialog_button( "Credits", G_CALLBACK( about_button_credits ), 0 );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Credits", G_CALLBACK( about_button_credits ), 0 );
+ vbox2.pack_start( button, FALSE, FALSE, 0 );
}
{
- GtkButton* button = create_dialog_button( "Changelog", G_CALLBACK( about_button_changelog ), 0 );
- gtk_box_pack_start( GTK_BOX( vbox2 ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Changes", G_CALLBACK( about_button_changelog ), 0 );
+ vbox2.pack_start( button, FALSE, FALSE, 0 );
+ }
+ {
+ auto button = create_dialog_button( "Issues", G_CALLBACK( about_button_issues ), 0 );
+ vbox2.pack_start( button, FALSE, FALSE, 0 );
}
}
}
{
- GtkFrame* frame = create_dialog_frame( "OpenGL Properties" );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 );
+ auto frame = create_dialog_frame( "OpenGL Properties" );
+ vbox.pack_start( frame, FALSE, FALSE, 0 );
{
- GtkTable* table = create_dialog_table( 3, 2, 4, 4, 4 );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( table ) );
+ auto table = create_dialog_table( 3, 2, 4, 4, 4 );
+ frame.add(table);
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Vendor:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Vendor:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Version:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Version:" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Renderer:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Renderer:" );
+ label.show();
+ table.attach(label, {0, 1, 2, 3}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast<const char*>( glGetString( GL_VENDOR ) ) ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( reinterpret_cast<const char*>( glGetString( GL_VENDOR ) ) );
+ label.show();
+ table.attach(label, {1, 2, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast<const char*>( glGetString( GL_VERSION ) ) ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( reinterpret_cast<const char*>( glGetString( GL_VERSION ) ) );
+ label.show();
+ table.attach(label, {1, 2, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( reinterpret_cast<const char*>( glGetString( GL_RENDERER ) ) ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 1, 2, 2, 3,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( reinterpret_cast<const char*>( glGetString( GL_RENDERER ) ) );
+ label.show();
+ table.attach(label, {1, 2, 2, 3}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
}
{
- GtkFrame* frame = create_dialog_frame( "OpenGL Extensions" );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), TRUE, TRUE, 0 );
+ auto frame = create_dialog_frame( "OpenGL Extensions" );
+ vbox.pack_start( frame, TRUE, TRUE, 0 );
{
- GtkScrolledWindow* sc_extensions = create_scrolled_window( GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS, 4 );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( sc_extensions ) );
+ auto sc_extensions = create_scrolled_window( ui::Policy::AUTOMATIC, ui::Policy::ALWAYS, 4 );
+ frame.add(sc_extensions);
{
- GtkWidget* text_extensions = gtk_text_view_new();
- gtk_text_view_set_editable( GTK_TEXT_VIEW( text_extensions ), FALSE );
- gtk_container_add( GTK_CONTAINER( sc_extensions ), text_extensions );
- GtkTextBuffer* buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( text_extensions ) );
- gtk_text_buffer_set_text( buffer, reinterpret_cast<const char*>( glGetString( GL_EXTENSIONS ) ), -1 );
- gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( text_extensions ), GTK_WRAP_WORD );
- gtk_widget_show( text_extensions );
+ auto text_extensions = ui::TextView(ui::New);
+ gtk_text_view_set_editable( text_extensions, FALSE );
+ sc_extensions.add(text_extensions);
+ text_extensions.text(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)));
+ gtk_text_view_set_wrap_mode( text_extensions, GTK_WRAP_WORD );
+ text_extensions.show();
}
}
}
modal_dialog_show( window, dialog );
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
}
// =============================================================================
ModalDialog dialog;
ModalDialogButton ok_button( dialog, eIDOK );
ModalDialogButton cancel_button( dialog, eIDCANCEL );
- GtkEntry* x;
- GtkEntry* y;
+ ui::Entry x{ui::null};
+ ui::Entry y{ui::null};
- GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Patch texture layout", dialog );
+ auto window = MainFrame_getWindow().create_modal_dialog_window("Patch texture layout", dialog );
- GtkAccelGroup* accel = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel );
+ auto accel = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture will be fit across the patch based\n"
+ auto label = ui::Label( "Texture will be fit across the patch based\n"
"on the x and y values given. Values of 1x1\n"
"will \"fit\" the texture. 2x2 will repeat\n"
- "it twice, etc." ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), TRUE, TRUE, 0 );
+ "it twice, etc." );
+ label.show();
+ vbox.pack_start( label, TRUE, TRUE, 0 );
gtk_label_set_justify( label, GTK_JUSTIFY_LEFT );
}
{
- GtkTable* table = create_dialog_table( 2, 2, 4, 4 );
- gtk_widget_show( GTK_WIDGET( table ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 );
+ auto table = create_dialog_table( 2, 2, 4, 4 );
+ table.show();
+ vbox.pack_start( table, TRUE, TRUE, 0 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture x:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Texture x:" );
+ label.show();
+ table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Texture y:" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 1, 2,
- (GtkAttachOptions) ( GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto label = ui::Label( "Texture y:" );
+ label.show();
+ table.attach(label, {0, 1, 1, 2}, {GTK_FILL, 0});
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 0, 1,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 0, 1}, {GTK_EXPAND | GTK_FILL, 0});
x = entry;
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_table_attach( table, GTK_WIDGET( entry ), 1, 2, 1, 2,
- (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
- (GtkAttachOptions) ( 0 ), 0, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ table.attach(entry, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
y = entry;
}
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
{
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
}
{
- GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
+ auto button = create_modal_dialog_button( "Cancel", cancel_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
}
}
}
char buf[16];
sprintf( buf, "%f", last_used_texture_layout_scale_x );
- gtk_entry_set_text( x, buf );
+ x.text( buf );
sprintf( buf, "%f", last_used_texture_layout_scale_y );
- gtk_entry_set_text( y, buf );
+ y.text( buf );
// Set focus after intializing the values
- gtk_widget_grab_focus( GTK_WIDGET( x ) );
+ gtk_widget_grab_focus( x );
EMessageBoxReturn ret = modal_dialog_show( window, dialog );
if ( ret == eIDOK ) {
last_used_texture_layout_scale_y = *fy;
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
return ret;
}
// Text Editor dialog
// master window widget
-static GtkWidget *text_editor = 0;
-static GtkWidget *text_widget; // slave, text widget from the gtk editor
+static ui::Window text_editor{ui::null};
+static ui::Widget text_widget{ui::null}; // 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 ) {
+static gint editor_delete( ui::Widget widget, gpointer data ){
- if ( ui::alert( widget.window(), "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
++/* if ( ui::alert( widget.window(), "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
return TRUE;
}
-
+ */
- gtk_widget_hide( text_editor );
+ text_editor.hide();
return TRUE;
}
-static void editor_save( GtkWidget *widget, gpointer data ){
+static void editor_save( ui::Widget 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 !" );
+ ui::alert( ui::Widget::from(data).window(), "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 ) {
+static void editor_close( ui::Widget widget, gpointer data ){
- if ( ui::alert( text_editor.window(), "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
++/* if ( ui::alert( text_editor.window(), "Close the shader editor ?", "Radiant", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::NO ) {
return;
}
-
+ */
- gtk_widget_hide( text_editor );
+ text_editor.hide();
}
static void CreateGtkTextEditor(){
- GtkWidget *dlg;
- GtkWidget *vbox, *hbox, *button, *scr, *text;
+ auto dlg = ui::Window( ui::window_type::TOP );
- dlg = gtk_window_new( GTK_WINDOW_TOPLEVEL );
-
- g_signal_connect( G_OBJECT( dlg ), "delete_event",
+ dlg.connect( "delete_event",
G_CALLBACK( editor_delete ), 0 );
- gtk_window_set_default_size( dlg, 600, 300 );
- gtk_window_set_default_size( GTK_WINDOW( dlg ), 400, 600 );
++ gtk_window_set_default_size( dlg, 400, 300 );
- vbox = gtk_vbox_new( FALSE, 5 );
- gtk_widget_show( vbox );
- gtk_container_add( GTK_CONTAINER( dlg ), GTK_WIDGET( vbox ) );
+ auto vbox = ui::VBox( FALSE, 5 );
+ vbox.show();
+ dlg.add(vbox);
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
- scr = gtk_scrolled_window_new( 0, 0 );
- gtk_widget_show( scr );
- gtk_box_pack_start( GTK_BOX( vbox ), scr, TRUE, TRUE, 0 );
+ auto scr = ui::ScrolledWindow(ui::New);
+ scr.show();
+ vbox.pack_start( scr, TRUE, TRUE, 0 );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scr ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
- text = gtk_text_view_new();
- gtk_container_add( GTK_CONTAINER( scr ), text );
- gtk_widget_show( text );
- g_object_set_data( G_OBJECT( dlg ), "text", text );
- gtk_text_view_set_editable( GTK_TEXT_VIEW( text ), TRUE );
+ auto text = ui::TextView(ui::New);
+ scr.add(text);
+ text.show();
+ g_object_set_data( G_OBJECT( dlg ), "text", (gpointer) text );
+ gtk_text_view_set_editable( text, TRUE );
- hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox ), FALSE, TRUE, 0 );
+ auto hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ vbox.pack_start( hbox, FALSE, TRUE, 0 );
- button = gtk_button_new_with_label( "Close" );
- gtk_widget_show( button );
- gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
+ auto button = ui::Button( "Close" );
+ button.show();
+ hbox.pack_end(button, FALSE, FALSE, 0);
+ button.connect( "clicked",
G_CALLBACK( editor_close ), dlg );
- gtk_widget_set_usize( button, 60, -2 );
+ button.dimensions(60, -1);
- button = gtk_button_new_with_label( "Save" );
- gtk_widget_show( button );
- gtk_box_pack_end( GTK_BOX( hbox ), button, FALSE, FALSE, 0 );
- g_signal_connect( G_OBJECT( button ), "clicked",
+ button = ui::Button( "Save" );
+ button.show();
+ hbox.pack_end(button, FALSE, FALSE, 0);
+ button.connect( "clicked",
G_CALLBACK( editor_save ), dlg );
- gtk_widget_set_usize( button, 60, -2 );
+ button.dimensions(60, -1);
text_editor = dlg;
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
if ( f == 0 ) {
globalOutputStream() << "Unable to load file " << filename << " in shader editor.\n";
- gtk_widget_hide( text_editor );
+ text_editor.hide();
}
else
{
rewind( f );
fread( buf, 1, len, f );
- gtk_window_set_title( GTK_WINDOW( text_editor ), filename );
+ gtk_window_set_title( text_editor, filename );
- GtkTextBuffer* text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW( text_widget ) );
+ auto text_buffer = gtk_text_view_get_buffer(ui::TextView::from(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 ) {
g_object_set_data( G_OBJECT( text_editor ), "filename", strdup( filename ) );
// trying to show later
- gtk_widget_show( text_editor );
+ text_editor.show();
-#ifdef WIN32
- process_gui();
+#if GDEF_OS_WINDOWS
+ ui::process();
#endif
// only move the cursor if it's not exceeding the size..
// 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
+#if GDEF_OS_WINDOWS
gtk_widget_queue_draw( text_widget );
#endif
+ text_buffer_ = text_buffer;
free( buf );
fclose( f );
}
EMessageBoxReturn DoLightIntensityDlg( int *intensity ){
ModalDialog dialog;
- GtkEntry* intensity_entry;
+ ui::Entry intensity_entry{ui::null};
ModalDialogButton ok_button( dialog, eIDOK );
ModalDialogButton cancel_button( dialog, eIDCANCEL );
- GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), "Light intensity", dialog, -1, -1 );
+ ui::Window window = MainFrame_getWindow().create_modal_dialog_window("Light intensity", dialog, -1, -1 );
- GtkAccelGroup *accel_group = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel_group );
+ auto accel_group = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel_group );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "ESC for default, ENTER to validate" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( "ESC for default, ENTER to validate" );
+ label.show();
+ vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
+ auto entry = ui::Entry(ui::New);
+ entry.show();
+ vbox.pack_start( entry, TRUE, TRUE, 0 );
- gtk_widget_grab_focus( GTK_WIDGET( entry ) );
+ gtk_widget_grab_focus( entry );
intensity_entry = entry;
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
{
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
}
{
- GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
+ auto button = create_modal_dialog_button( "Cancel", cancel_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
}
}
}
char buf[16];
sprintf( buf, "%d", *intensity );
- gtk_entry_set_text( intensity_entry, buf );
+ intensity_entry.text(buf);
EMessageBoxReturn ret = modal_dialog_show( window, dialog );
if ( ret == eIDOK ) {
*intensity = atoi( gtk_entry_get_text( intensity_entry ) );
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
return ret;
}
// =============================================================================
// Add new shader tag dialog
-EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, char* title ){
+EMessageBoxReturn DoShaderTagDlg( CopiedString* tag, const char* title ){
ModalDialog dialog;
- GtkEntry* textentry;
ModalDialogButton ok_button( dialog, eIDOK );
ModalDialogButton cancel_button( dialog, eIDCANCEL );
- GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), title, dialog, -1, -1 );
+ auto window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 );
- GtkAccelGroup *accel_group = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel_group );
+ auto accel_group = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel_group );
+ auto textentry = ui::Entry(ui::New);
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, TRUE, TRUE, 0 );
{
//GtkLabel* label = GTK_LABEL(gtk_label_new("Enter one ore more tags separated by spaces"));
- GtkLabel* label = GTK_LABEL( gtk_label_new( "ESC to cancel, ENTER to validate" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( "ESC to cancel, ENTER to validate" );
+ label.show();
+ vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
- gtk_widget_show( GTK_WIDGET( entry ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( entry ), TRUE, TRUE, 0 );
-
- gtk_widget_grab_focus( GTK_WIDGET( entry ) );
+ auto entry = textentry;
+ entry.show();
+ vbox.pack_start( entry, TRUE, TRUE, 0 );
- textentry = entry;
+ gtk_widget_grab_focus( entry );
}
}
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
{
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
}
{
- GtkButton* button = create_modal_dialog_button( "Cancel", cancel_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
+ auto button = create_modal_dialog_button( "Cancel", cancel_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Escape, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
}
}
}
*tag = gtk_entry_get_text( textentry );
}
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
return ret;
}
-EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* title ){
+EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, const char* title ){
ModalDialog dialog;
ModalDialogButton ok_button( dialog, eIDOK );
- GtkWindow* window = create_modal_dialog_window( MainFrame_getWindow(), title, dialog, -1, -1 );
+ auto window = MainFrame_getWindow().create_modal_dialog_window(title, dialog, -1, -1 );
- GtkAccelGroup *accel_group = gtk_accel_group_new();
- gtk_window_add_accel_group( window, accel_group );
+ auto accel_group = ui::AccelGroup(ui::New);
+ window.add_accel_group( accel_group );
{
- GtkHBox* hbox = create_dialog_hbox( 4, 4 );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) );
+ auto hbox = create_dialog_hbox( 4, 4 );
+ window.add(hbox);
{
- GtkVBox* vbox = create_dialog_vbox( 4 );
- gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), FALSE, FALSE, 0 );
+ auto vbox = create_dialog_vbox( 4 );
+ hbox.pack_start( vbox, FALSE, FALSE, 0 );
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "The selected shader" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( "The selected shader" );
+ label.show();
+ vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( name ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( name );
+ label.show();
+ vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "is located in file" ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( "is located in file" );
+ label.show();
+ vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( filename ) );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( label ), FALSE, FALSE, 0 );
+ auto label = ui::Label( filename );
+ label.show();
+ vbox.pack_start( label, FALSE, FALSE, 0 );
}
{
- GtkButton* button = create_modal_dialog_button( "OK", ok_button );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
- widget_make_default( GTK_WIDGET( button ) );
- gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel_group, GDK_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
+ auto button = create_modal_dialog_button( "OK", ok_button );
+ vbox.pack_start( button, FALSE, FALSE, 0 );
+ widget_make_default( button );
+ gtk_widget_add_accelerator( button , "clicked", accel_group, GDK_KEY_Return, (GdkModifierType)0, GTK_ACCEL_VISIBLE );
}
}
}
EMessageBoxReturn ret = modal_dialog_show( window, dialog );
- gtk_widget_destroy( GTK_WIDGET( window ) );
+ window.destroy();
return ret;
}
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <gdk/gdkwin32.h>
#endif
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
// 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 GDEF_OS_WINDOWS
if ( g_TextEditor_useWin32Editor ) {
- globalOutputStream() << "opening file '" << filename << "' (line " << cursorpos << " info ignored)\n";
- ShellExecute( (HWND)GDK_WINDOW_HWND( gtk_widget_get_window( MainFrame_getWindow() ) ), "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 );
++ ShellExecute( (HWND)GDK_WINDOW_HWND( gtk_widget_get_window( MainFrame_getWindow() ) ), "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 );
++ ShellExecute( (HWND)GDK_WINDOW_HWND( gtk_widget_get_window( MainFrame_getWindow() ) ), "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
}
#if !defined( INCLUDED_GTKDLGS_H )
#define INCLUDED_GTKDLGS_H
+#include "globaldefs.h"
#include "qerplugin.h"
#include "string/string.h"
EMessageBoxReturn DoLightIntensityDlg( int *intensity );
-EMessageBoxReturn DoShaderTagDlg( CopiedString *tag, char* title );
-EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* title );
+EMessageBoxReturn DoShaderTagDlg( CopiedString *tag, const char* title );
+EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, const char* title );
EMessageBoxReturn DoTextureLayout( float *fx, float *fy );
- void DoTextEditor( const char* filename, int cursorpos );
+ void DoTextEditor( const char* filename, int cursorpos, int length );
void DoProjectSettings();
void DoAbout();
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
extern bool g_TextEditor_useWin32Editor;
#else
#include "string/stringfwd.h"
//
#include "mainframe.h"
+#include "globaldefs.h"
-#include "debugging/debugging.h"
-#include "version.h"
+#include <gtk/gtk.h>
#include "ifilesystem.h"
#include "iundo.h"
-#include "ifilter.h"
-#include "itoolbar.h"
#include "editable.h"
#include "ientity.h"
#include "ishaders.h"
#include <ctime>
#include <gdk/gdkkeysyms.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtkhpaned.h>
-#include <gtk/gtkvpaned.h>
-#include <gtk/gtktoolbar.h>
-#include <gtk/gtkmenubar.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtktable.h>
#include "cmdlib.h"
-#include "scenelib.h"
#include "stream/stringstream.h"
#include "signal/isignal.h"
#include "os/path.h"
#include "moduleobservers.h"
#include "gtkutil/clipboard.h"
-#include "gtkutil/container.h"
#include "gtkutil/frame.h"
-#include "gtkutil/glfont.h"
#include "gtkutil/glwidget.h"
#include "gtkutil/image.h"
#include "gtkutil/menu.h"
#include "gtkutil/paned.h"
-#include "gtkutil/widget.h"
#include "autosave.h"
#include "build.h"
#include "pluginmanager.h"
#include "pluginmenu.h"
#include "plugintoolbar.h"
-#include "points.h"
#include "preferences.h"
#include "qe3.h"
#include "qgl.h"
#include "renderstate.h"
#include "feedback.h"
#include "referencecache.h"
-
+#include "texwindow.h"
struct layout_globals_t
// VFS
+
+bool g_vfsInitialized = false;
+
+void VFS_Init(){
+ if ( g_vfsInitialized ) return;
+ QE_InitVFS();
+ GlobalFileSystem().initialise();
+ g_vfsInitialized = true;
+}
+
+void VFS_Shutdown(){
+ if ( !g_vfsInitialized ) return;
+ GlobalFileSystem().shutdown();
+ g_vfsInitialized = false;
+}
+
+void VFS_Refresh(){
+ if ( !g_vfsInitialized ) return;
+ GlobalFileSystem().clear();
+ QE_InitVFS();
+ GlobalFileSystem().refresh();
+ g_vfsInitialized = true;
+ // also refresh models
+ RefreshReferences();
+ // also refresh texture browser
+ TextureBrowser_RefreshShaders();
+}
+
+void VFS_Restart(){
+ VFS_Shutdown();
+ VFS_Init();
+}
+
class VFSModuleObserver : public ModuleObserver
{
-std::size_t m_unrealised;
public:
-VFSModuleObserver() : m_unrealised( 1 ){
-}
void realise(){
- if ( --m_unrealised == 0 ) {
- QE_InitVFS();
- GlobalFileSystem().initialise();
+ VFS_Init();
}
-}
+
void unrealise(){
- if ( ++m_unrealised == 1 ) {
- GlobalFileSystem().shutdown();
- }
+ VFS_Shutdown();
}
};
void VFS_Construct(){
Radiant_attachHomePathsObserver( g_VFSModuleObserver );
}
+
void VFS_Destroy(){
Radiant_detachHomePathsObserver( g_VFSModuleObserver );
}
// Home Paths
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <shlobj.h>
#include <objbase.h>
const GUID qFOLDERID_SavedGames = {0x4C5C32FF, 0xBB9D, 0x43b0, {0xB5, 0xB4, 0x2D, 0x72, 0xE5, 0x4E, 0xAA, 0xA4}};
typedef HRESULT ( WINAPI qSHGetKnownFolderPath_t )( qREFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath );
static qSHGetKnownFolderPath_t *qSHGetKnownFolderPath;
#endif
+
void HomePaths_Realise(){
do
{
if ( !string_empty( prefix ) ) {
StringOutputStream path( 256 );
-#if defined( __APPLE__ )
+#if GDEF_OS_MACOS
path.clear();
path << DirectoryCleaned( g_get_home_dir() ) << "Library/Application Support" << ( prefix + 1 ) << "/";
if ( file_is_directory( path.c_str() ) ) {
g_qeglobals.m_userEnginePath = path.c_str();
break;
}
+ path.clear();
+ path << DirectoryCleaned( g_get_home_dir() ) << prefix << "/";
#endif
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
TCHAR mydocsdir[MAX_PATH + 1];
wchar_t *mydocsdirw;
HMODULE shfolder = LoadLibrary( "shfolder.dll" );
}
#endif
-#if defined( POSIX )
+#if GDEF_OS_POSIX
path.clear();
path << DirectoryCleaned( g_get_home_dir() ) << prefix << "/";
g_qeglobals.m_userEnginePath = path.c_str();
public:
HomePathsModuleObserver() : m_unrealised( 1 ){
}
+
void realise(){
if ( --m_unrealised == 0 ) {
HomePaths_Realise();
g_homePathObservers.realise();
}
}
+
void unrealise(){
if ( ++m_unrealised == 1 ) {
g_homePathObservers.unrealise();
void HomePaths_Construct(){
Radiant_attachEnginePathObserver( g_HomePathsModuleObserver );
}
+
void HomePaths_Destroy(){
Radiant_detachEnginePathObserver( g_HomePathsModuleObserver );
}
}
}
+// Pak Path
+
+CopiedString g_strPakPath[g_pakPathCount] = { "", "", "", "", "" };
+ModuleObservers g_pakPathObservers[g_pakPathCount];
+std::size_t g_pakpath_unrealised[g_pakPathCount] = { 1, 1, 1, 1, 1 };
+
+void Radiant_attachPakPathObserver( int num, ModuleObserver& observer ){
+ g_pakPathObservers[num].attach( observer );
+}
+
+void Radiant_detachPakPathObserver( int num, ModuleObserver& observer ){
+ g_pakPathObservers[num].detach( observer );
+}
+
+
+void PakPath_Realise( int num ){
+ if ( --g_pakpath_unrealised[num] == 0 ) {
+ g_pakPathObservers[num].realise();
+ }
+}
+
+const char* PakPath_get( int num ){
+ std::string message = "PakPath_get: pak path " + std::to_string(num) + " not realised";
+ ASSERT_MESSAGE( g_pakpath_unrealised[num] == 0, message.c_str() );
+ return g_strPakPath[num].c_str();
+}
+
+void PakPath_Unrealise( int num ){
+ if ( ++g_pakpath_unrealised[num] == 1 ) {
+ g_pakPathObservers[num].unrealise();
+ }
+}
+
+void setPakPath( int num, const char* path ){
+ if (!g_strcmp0( path, "")) {
+ g_strPakPath[num] = "";
+ return;
+ }
+
+ StringOutputStream buffer( 256 );
+ buffer << DirectoryCleaned( path );
+ if ( !path_equal( buffer.c_str(), g_strPakPath[num].c_str() ) ) {
+ std::string message = "Changing Pak Path " + std::to_string(num);
+ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", message.c_str() );
+
+ PakPath_Unrealise(num);
+
+ g_strPakPath[num] = buffer.c_str();
+
+ PakPath_Realise(num);
+ }
+}
+
// App Path
/// directory for temp files
/// NOTE: on *nix this is were we check for .pid
CopiedString g_strSettingsPath;
+
const char* SettingsPath_get(){
return g_strSettingsPath.c_str();
}
return g_strGameToolsPath.c_str();
}
-void EnginePathImport( CopiedString& self, const char* value ){
+struct EnginePath {
+ static void Export(const CopiedString &self, const Callback<void(const char *)> &returnz) {
+ returnz(self.c_str());
+ }
+
+ static void Import(CopiedString &self, const char *value) {
setEnginePath( value );
}
-typedef ReferenceCaller1<CopiedString, const char*, EnginePathImport> EnginePathImportCaller;
+};
+
+struct PakPath0 {
+ static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
+ returnz( self.c_str() );
+ }
+
+ static void Import( CopiedString &self, const char *value ) {
+ setPakPath( 0, value );
+ }
+};
+
+struct PakPath1 {
+ static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
+ returnz( self.c_str() );
+ }
+
+ static void Import( CopiedString &self, const char *value ) {
+ setPakPath( 1, value );
+ }
+};
+
+struct PakPath2 {
+ static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
+ returnz( self.c_str() );
+ }
+
+ static void Import( CopiedString &self, const char *value ) {
+ setPakPath( 2, value );
+ }
+};
+
+struct PakPath3 {
+ static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
+ returnz( self.c_str() );
+ }
+
+ static void Import( CopiedString &self, const char *value ) {
+ setPakPath( 3, value );
+ }
+};
+
+struct PakPath4 {
+ static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
+ returnz( self.c_str() );
+ }
+
+ static void Import( CopiedString &self, const char *value ) {
+ setPakPath( 4, value );
+ }
+};
+
+bool g_disableEnginePath = false;
+bool g_disableHomePath = false;
void Paths_constructPreferences( PreferencesPage& page ){
- page.appendPathEntry( "Engine Path", true,
- StringImportCallback( EnginePathImportCaller( g_strEnginePath ) ),
- StringExportCallback( StringExportCaller( g_strEnginePath ) )
+ page.appendPathEntry( "Engine Path", true, make_property<EnginePath>(g_strEnginePath) );
+
+ page.appendCheckBox(
+ "", "Do not use Engine Path",
+ g_disableEnginePath
);
+
+ page.appendCheckBox(
+ "", "Do not use Home Path",
+ g_disableHomePath
+ );
+
+ for ( int i = 0; i < g_pakPathCount; i++ ) {
+ std::string label = "Pak Path " + std::to_string(i);
+ switch (i) {
+ case 0:
+ page.appendPathEntry( label.c_str(), true, make_property<PakPath0>( g_strPakPath[i] ) );
+ break;
+ case 1:
+ page.appendPathEntry( label.c_str(), true, make_property<PakPath1>( g_strPakPath[i] ) );
+ break;
+ case 2:
+ page.appendPathEntry( label.c_str(), true, make_property<PakPath2>( g_strPakPath[i] ) );
+ break;
+ case 3:
+ page.appendPathEntry( label.c_str(), true, make_property<PakPath3>( g_strPakPath[i] ) );
+ break;
+ case 4:
+ page.appendPathEntry( label.c_str(), true, make_property<PakPath4>( g_strPakPath[i] ) );
+ break;
+}
+ }
}
+
void Paths_constructPage( PreferenceGroup& group ){
PreferencesPage page( group.createPage( "Paths", "Path Settings" ) );
Paths_constructPreferences( page );
}
+
void Paths_registerPreferencesPage(){
- PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Paths_constructPage>() );
+ PreferencesDialog_addSettingsPage( makeCallbackF(Paths_constructPage) );
}
class PathsDialog : public Dialog
{
public:
-GtkWindow* BuildDialog(){
- GtkFrame* frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN );
+ui::Window BuildDialog(){
+ auto frame = create_dialog_frame( "Path settings", ui::Shadow::ETCHED_IN );
- GtkVBox* vbox2 = create_dialog_vbox( 0, 4 );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) );
+ auto vbox2 = create_dialog_vbox( 0, 4 );
+ frame.add(vbox2);
{
- PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) );
+ PreferencesPage preferencesPage( *this, vbox2 );
Paths_constructPreferences( preferencesPage );
}
- return create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, GTK_WIDGET( frame ) );
+ return ui::Window(create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, frame ));
}
};
}
}
-#include "os/dir.h"
-class CLoadModule
-{
-const char* m_path;
-public:
-CLoadModule( const char* path ) : m_path( path ){
-}
-void operator()( const char* name ) const {
- char fullname[1024];
- ASSERT_MESSAGE( strlen( m_path ) + strlen( name ) < 1024, "" );
- strcpy( fullname, m_path );
- strcat( fullname, name );
- globalOutputStream() << "Found '" << fullname << "'\n";
- GlobalModuleServer_loadModule( fullname );
-}
-};
+#include "os/dir.h"
const char* const c_library_extension =
-#if defined( WIN32 )
+#if defined( CMAKE_SHARED_MODULE_SUFFIX )
+ CMAKE_SHARED_MODULE_SUFFIX
+#elif GDEF_OS_WINDOWS
"dll"
-#elif defined ( __APPLE__ )
+#elif GDEF_OS_MACOS
"dylib"
-#elif defined( __linux__ ) || defined ( __FreeBSD__ )
+#elif GDEF_OS_LINUX || GDEF_OS_BSD
"so"
#endif
;
void Radiant_loadModules( const char* path ){
- Directory_forEach( path, MatchFileExtension<CLoadModule>( c_library_extension, CLoadModule( path ) ) );
+ Directory_forEach(path, matchFileExtension(c_library_extension, [&](const char *name) {
+ char fullname[1024];
+ ASSERT_MESSAGE(strlen(path) + strlen(name) < 1024, "");
+ strcpy(fullname, path);
+ strcat(fullname, name);
+ globalOutputStream() << "Found '" << fullname << "'\n";
+ GlobalModuleServer_loadModule(fullname);
+ }));
}
void Radiant_loadModulesFromRoot( const char* directory ){
public:
WorldspawnColourEntityClassObserver() : m_unrealised( 1 ){
}
+
void realise(){
if ( --m_unrealised == 0 ) {
SetWorldspawnColour( g_xywindow_globals.color_brushes );
}
}
+
void unrealise(){
if ( ++m_unrealised == 1 ) {
}
XY_UpdateAllWindows();
}
-typedef Callback1<Vector3&> GetColourCallback;
-typedef Callback1<const Vector3&> SetColourCallback;
+typedef Callback<void(Vector3&)> GetColourCallback;
+typedef Callback<void(const Vector3&)> SetColourCallback;
class ChooseColour
{
ChooseColour( const GetColourCallback& get, const SetColourCallback& set )
: m_get( get ), m_set( set ){
}
+
void operator()(){
Vector3 colour;
m_get( colour );
- color_dialog( GTK_WIDGET( MainFrame_getWindow() ), colour );
+ color_dialog( MainFrame_getWindow(), colour );
m_set( colour );
}
};
-
void Colour_get( const Vector3& colour, Vector3& other ){
other = colour;
}
-typedef ConstReferenceCaller1<Vector3, Vector3&, Colour_get> ColourGetCaller;
+
+typedef ConstReferenceCaller<Vector3, void(Vector3&), Colour_get> ColourGetCaller;
void Colour_set( Vector3& colour, const Vector3& other ){
colour = other;
SceneChangeNotify();
}
-typedef ReferenceCaller1<Vector3, const Vector3&, Colour_set> ColourSetCaller;
+
+typedef ReferenceCaller<Vector3, void(const Vector3&), Colour_set> ColourSetCaller;
void BrushColour_set( const Vector3& other ){
g_xywindow_globals.color_brushes = other;
SetWorldspawnColour( g_xywindow_globals.color_brushes );
SceneChangeNotify();
}
-typedef FreeCaller1<const Vector3&, BrushColour_set> BrushColourSetCaller;
+
+typedef FreeCaller<void(const Vector3&), BrushColour_set> BrushColourSetCaller;
void ClipperColour_set( const Vector3& other ){
g_xywindow_globals.color_clipper = other;
Brush_clipperColourChanged();
SceneChangeNotify();
}
-typedef FreeCaller1<const Vector3&, ClipperColour_set> ClipperColourSetCaller;
+
+typedef FreeCaller<void(const Vector3&), ClipperColour_set> ClipperColourSetCaller;
void TextureBrowserColour_get( Vector3& other ){
other = TextureBrowser_getBackgroundColour( GlobalTextureBrowser() );
}
-typedef FreeCaller1<Vector3&, TextureBrowserColour_get> TextureBrowserColourGetCaller;
+
+typedef FreeCaller<void(Vector3&), TextureBrowserColour_get> TextureBrowserColourGetCaller;
void TextureBrowserColour_set( const Vector3& other ){
TextureBrowser_setBackgroundColour( GlobalTextureBrowser(), other );
}
-typedef FreeCaller1<const Vector3&, TextureBrowserColour_set> TextureBrowserColourSetCaller;
+
+typedef FreeCaller<void(const Vector3&), TextureBrowserColour_set> TextureBrowserColourSetCaller;
class ColoursMenu
ColoursMenu g_ColoursMenu;
-GtkMenuItem* create_colours_menu(){
- GtkMenuItem* colours_menu_item = new_sub_menu_item_with_mnemonic( "Colors" );
- GtkMenu* menu_in_menu = GTK_MENU( gtk_menu_item_get_submenu( colours_menu_item ) );
+ui::MenuItem create_colours_menu(){
+ auto colours_menu_item = new_sub_menu_item_with_mnemonic( "Colors" );
+ auto menu_in_menu = ui::Menu::from( gtk_menu_item_get_submenu( colours_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
- GtkMenu* menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Themes" );
+ auto menu_3 = create_sub_menu_with_mnemonic( menu_in_menu, "Themes" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_3 );
}
g_pParentWnd->OnSleep();
}
-void OpenUpdateURL(){
- // build the URL
- StringOutputStream URL( 256 );
- URL << "http://www.icculus.org/netradiant/?cmd=update&data=dlupdate&query_dlup=1";
-#ifdef WIN32
- URL << "&OS_dlup=1";
-#elif defined( __APPLE__ )
- URL << "&OS_dlup=2";
-#else
- URL << "&OS_dlup=3";
-#endif
- URL << "&Version_dlup=" RADIANT_VERSION;
- g_GamesDialog.AddPacksURL( URL );
- OpenURL( URL.c_str() );
-}
-
-// open the Q3Rad manual
void OpenHelpURL(){
- // at least on win32, AppPath + "docs/index.html"
- StringOutputStream help( 256 );
- help << AppPath_get() << "docs/index.html";
- OpenURL( help.c_str() );
+ OpenURL( "https://gitlab.com/xonotic/xonotic/wikis/Mapping" );
}
void OpenBugReportURL(){
- OpenURL( "http://www.icculus.org/netradiant/?cmd=bugs" );
+ OpenURL( "https://gitlab.com/xonotic/netradiant/issues" );
}
-GtkWidget* g_page_console;
+ui::Widget g_page_console{ui::null};
void Console_ToggleShow(){
GroupDialog_showPage( g_page_console );
}
-GtkWidget* g_page_entity;
+ui::Widget g_page_entity{ui::null};
void EntityInspector_ToggleShow(){
GroupDialog_showPage( g_page_entity );
}
-
void SetClipMode( bool enable );
+
void ModeChangeNotify();
typedef void ( *ToolMode )();
+
ToolMode g_currentToolMode = 0;
bool g_currentToolModeSupportsComponentEditing = false;
ToolMode g_defaultToolMode = 0;
-
void SelectionSystem_DefaultMode(){
GlobalSelectionSystem().SetMode( SelectionSystem::ePrimitive );
GlobalSelectionSystem().SetComponentMode( SelectionSystem::eDefault );
class BoolFunctionExport
{
public:
-static void apply( const BoolImportCallback& importCallback ){
+static void apply( const Callback<void(bool)> & importCallback ){
importCallback( BoolFunction() );
}
};
-typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<EdgeMode>::apply> EdgeModeApplyCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), &BoolFunctionExport<EdgeMode>::apply> EdgeModeApplyCaller;
EdgeModeApplyCaller g_edgeMode_button_caller;
-BoolExportCallback g_edgeMode_button_callback( g_edgeMode_button_caller );
+Callback<void(const Callback<void(bool)> &)> g_edgeMode_button_callback( g_edgeMode_button_caller );
ToggleItem g_edgeMode_button( g_edgeMode_button_callback );
-typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<VertexMode>::apply> VertexModeApplyCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), &BoolFunctionExport<VertexMode>::apply> VertexModeApplyCaller;
VertexModeApplyCaller g_vertexMode_button_caller;
-BoolExportCallback g_vertexMode_button_callback( g_vertexMode_button_caller );
+Callback<void(const Callback<void(bool)> &)> g_vertexMode_button_callback( g_vertexMode_button_caller );
ToggleItem g_vertexMode_button( g_vertexMode_button_callback );
-typedef FreeCaller1<const BoolImportCallback&, &BoolFunctionExport<FaceMode>::apply> FaceModeApplyCaller;
+typedef FreeCaller<void(const Callback<void(bool)> &), &BoolFunctionExport<FaceMode>::apply> FaceModeApplyCaller;
FaceModeApplyCaller g_faceMode_button_caller;
-BoolExportCallback g_faceMode_button_callback( g_faceMode_button_caller );
+Callback<void(const Callback<void(bool)> &)> g_faceMode_button_callback( g_faceMode_button_caller );
ToggleItem g_faceMode_button( g_faceMode_button_callback );
void ComponentModeChanged(){
public:
CloneSelected( bool d ) : doMakeUnique( d ), worldspawn( Map_FindOrInsertWorldspawn( g_map ) ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.size() == 1 ) {
return true;
return true;
}
+
void post( const scene::Path& path, scene::Instance& instance ) const {
if ( path.size() == 1 ) {
return;
Vector3 x;
Vector3 y;
Vector3 z;
+
AxisBase( const Vector3& x_, const Vector3& y_, const Vector3& z_ )
: x( x_ ), y( y_ ), z( z_ ){
}
}
-void TranslateToolExport( const BoolImportCallback& importCallback ){
+void TranslateToolExport( const Callback<void(bool)> & importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eTranslate );
}
-void RotateToolExport( const BoolImportCallback& importCallback ){
+void RotateToolExport( const Callback<void(bool)> & importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eRotate );
}
-void ScaleToolExport( const BoolImportCallback& importCallback ){
+void ScaleToolExport( const Callback<void(bool)> & importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eScale );
}
-void DragToolExport( const BoolImportCallback& importCallback ){
+void DragToolExport( const Callback<void(bool)> & importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eDrag );
}
-void ClipperToolExport( const BoolImportCallback& importCallback ){
+void ClipperToolExport( const Callback<void(bool)> & importCallback ){
importCallback( GlobalSelectionSystem().ManipulatorMode() == SelectionSystem::eClip );
}
-FreeCaller1<const BoolImportCallback&, TranslateToolExport> g_translatemode_button_caller;
-BoolExportCallback g_translatemode_button_callback( g_translatemode_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), TranslateToolExport> g_translatemode_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_translatemode_button_callback( g_translatemode_button_caller );
ToggleItem g_translatemode_button( g_translatemode_button_callback );
-FreeCaller1<const BoolImportCallback&, RotateToolExport> g_rotatemode_button_caller;
-BoolExportCallback g_rotatemode_button_callback( g_rotatemode_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), RotateToolExport> g_rotatemode_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_rotatemode_button_callback( g_rotatemode_button_caller );
ToggleItem g_rotatemode_button( g_rotatemode_button_callback );
-FreeCaller1<const BoolImportCallback&, ScaleToolExport> g_scalemode_button_caller;
-BoolExportCallback g_scalemode_button_callback( g_scalemode_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), ScaleToolExport> g_scalemode_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_scalemode_button_callback( g_scalemode_button_caller );
ToggleItem g_scalemode_button( g_scalemode_button_callback );
-FreeCaller1<const BoolImportCallback&, DragToolExport> g_dragmode_button_caller;
-BoolExportCallback g_dragmode_button_callback( g_dragmode_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), DragToolExport> g_dragmode_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_dragmode_button_callback( g_dragmode_button_caller );
ToggleItem g_dragmode_button( g_dragmode_button_callback );
-FreeCaller1<const BoolImportCallback&, ClipperToolExport> g_clipper_button_caller;
-BoolExportCallback g_clipper_button_callback( g_clipper_button_caller );
+FreeCaller<void(const Callback<void(bool)> &), ClipperToolExport> g_clipper_button_caller;
+Callback<void(const Callback<void(bool)> &)> g_clipper_button_callback( g_clipper_button_caller );
ToggleItem g_clipper_button( g_clipper_button_callback );
void ToolChanged(){
SnappableSnapToGridSelected( float snap )
: m_snap( snap ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
Snappable* snappable = Node_getSnappable( path.top() );
ComponentSnappableSnapToGridSelected( float snap )
: m_snap( snap ){
}
+
bool pre( const scene::Path& path, scene::Instance& instance ) const {
if ( path.top().get().visible() ) {
ComponentSnappable* componentSnappable = Instance_getComponentSnappable( instance );
void EverySecondTimer_enable(){
if ( s_qe_every_second_id == 0 ) {
- s_qe_every_second_id = gtk_timeout_add( 1000, qe_every_second, 0 );
+ s_qe_every_second_id = g_timeout_add( 1000, qe_every_second, 0 );
}
}
void EverySecondTimer_disable(){
if ( s_qe_every_second_id != 0 ) {
- gtk_timeout_remove( s_qe_every_second_id );
+ g_source_remove( s_qe_every_second_id );
s_qe_every_second_id = 0;
}
}
-gint window_realize_remove_decoration( GtkWidget* widget, gpointer data ){
- gdk_window_set_decorations( widget->window, (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) );
+gint window_realize_remove_decoration( ui::Widget widget, gpointer data ){
+ gdk_window_set_decorations( gtk_widget_get_window(widget), (GdkWMDecoration)( GDK_DECOR_ALL | GDK_DECOR_MENU | GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE ) );
return FALSE;
}
class WaitDialog
{
public:
-GtkWindow* m_window;
-GtkLabel* m_label;
+ui::Window m_window{ui::null};
+ui::Label m_label{ui::null};
};
WaitDialog create_wait_dialog( const char* title, const char* text ){
WaitDialog dialog;
- dialog.m_window = create_floating_window( title, MainFrame_getWindow() );
+ dialog.m_window = MainFrame_getWindow().create_floating_window(title);
gtk_window_set_resizable( dialog.m_window, FALSE );
gtk_container_set_border_width( GTK_CONTAINER( dialog.m_window ), 0 );
gtk_window_set_position( dialog.m_window, GTK_WIN_POS_CENTER_ON_PARENT );
- g_signal_connect( G_OBJECT( dialog.m_window ), "realize", G_CALLBACK( window_realize_remove_decoration ), 0 );
+ dialog.m_window.connect( "realize", G_CALLBACK( window_realize_remove_decoration ), 0 );
{
- dialog.m_label = GTK_LABEL( gtk_label_new( text ) );
+ dialog.m_label = ui::Label( text );
gtk_misc_set_alignment( GTK_MISC( dialog.m_label ), 0.0, 0.5 );
gtk_label_set_justify( dialog.m_label, GTK_JUSTIFY_LEFT );
- gtk_widget_show( GTK_WIDGET( dialog.m_label ) );
- gtk_widget_set_size_request( GTK_WIDGET( dialog.m_label ), 200, -1 );
+ dialog.m_label.show();
+ dialog.m_label.dimensions(200, -1);
- gtk_container_add( GTK_CONTAINER( dialog.m_window ), GTK_WIDGET( dialog.m_label ) );
+ dialog.m_window.add(dialog.m_label);
}
return dialog;
}
for ( GList* i = list; i != 0; i = g_list_next( i ) )
{
//globalOutputStream() << "toplevel.. ";
- if ( gtk_window_is_active( GTK_WINDOW( i->data ) ) ) {
+ if ( gtk_window_is_active( ui::Window::from( i->data ) ) ) {
//globalOutputStream() << "is active\n";
return true;
}
}
void ScreenUpdates_process(){
- if ( redrawRequired() && GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
- process_gui();
+ if ( redrawRequired() && g_wait.m_window.visible() ) {
+ ui::process();
}
}
if ( g_wait_stack.empty() ) {
EverySecondTimer_disable();
- process_gui();
+ ui::process();
bool isActiveApp = MainFrame_isActiveApp();
g_wait = create_wait_dialog( title, message );
- gtk_grab_add( GTK_WIDGET( g_wait.m_window ) );
+ gtk_grab_add( g_wait.m_window );
if ( isActiveApp ) {
- gtk_widget_show( GTK_WIDGET( g_wait.m_window ) );
+ g_wait.m_window.show();
ScreenUpdates_process();
}
}
- else if ( GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
- gtk_label_set_text( g_wait.m_label, message );
+ else if ( g_wait.m_window.visible() ) {
+ g_wait.m_label.text(message);
ScreenUpdates_process();
}
g_wait_stack.push_back( message );
g_wait_stack.pop_back();
if ( g_wait_stack.empty() ) {
EverySecondTimer_enable();
- //gtk_widget_set_sensitive(GTK_WIDGET(MainFrame_getWindow()), TRUE);
+ //gtk_widget_set_sensitive(MainFrame_getWindow(), TRUE);
- gtk_grab_remove( GTK_WIDGET( g_wait.m_window ) );
+ gtk_grab_remove( g_wait.m_window );
destroy_floating_window( g_wait.m_window );
- g_wait.m_window = 0;
+ g_wait.m_window = ui::Window{ui::null};
//gtk_window_present(MainFrame_getWindow());
}
- else if ( GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
- gtk_label_set_text( g_wait.m_label, g_wait_stack.back().c_str() );
+ else if ( g_wait.m_window.visible() ) {
+ g_wait.m_label.text(g_wait_stack.back().c_str());
ScreenUpdates_process();
}
}
-
void GlobalCamera_UpdateWindow(){
if ( g_pParentWnd != 0 ) {
CamWnd_Update( *g_pParentWnd->GetCamWnd() );
}
-LatchedInt g_Layout_viewStyle( 0, "Window Layout" );
-LatchedBool g_Layout_enableDetachableMenus( true, "Detachable Menus" );
-LatchedBool g_Layout_enablePatchToolbar( true, "Patch Toolbar" );
-LatchedBool g_Layout_enablePluginToolbar( true, "Plugin Toolbar" );
-LatchedBool g_Layout_enableFilterToolbar( true, "Filter Toolbar" );
-
+LatchedValue<int> g_Layout_viewStyle( 0, "Window Layout" );
+LatchedValue<bool> g_Layout_enableDetachableMenus( true, "Detachable Menus" );
+LatchedValue<bool> g_Layout_enablePatchToolbar( true, "Patch Toolbar" );
+LatchedValue<bool> g_Layout_enablePluginToolbar( true, "Plugin Toolbar" );
++LatchedValue<bool> g_Layout_enableFilterToolbar( true, "Filter Toolbar" );
-GtkMenuItem* create_file_menu(){
+ui::MenuItem create_file_menu(){
// File menu
- GtkMenuItem* file_menu_item = new_sub_menu_item_with_mnemonic( "_File" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( file_menu_item ) );
+ auto file_menu_item = new_sub_menu_item_with_mnemonic( "_File" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( file_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
create_menu_item_with_mnemonic( menu, "_Import...", "ImportMap" );
create_menu_item_with_mnemonic( menu, "_Save", "SaveMap" );
create_menu_item_with_mnemonic( menu, "Save _as...", "SaveMapAs" );
- create_menu_item_with_mnemonic( menu, "Save s_elected...", "SaveSelected" );
+ create_menu_item_with_mnemonic( menu, "_Export selected...", "ExportSelected" );
menu_separator( menu );
create_menu_item_with_mnemonic( menu, "Save re_gion...", "SaveRegion" );
// menu_separator( menu );
return file_menu_item;
}
-GtkMenuItem* create_edit_menu(){
+ui::MenuItem create_edit_menu(){
// Edit menu
- GtkMenuItem* edit_menu_item = new_sub_menu_item_with_mnemonic( "_Edit" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( edit_menu_item ) );
+ auto edit_menu_item = new_sub_menu_item_with_mnemonic( "_Edit" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( edit_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
menu_separator( menu );
-// GtkMenu* convert_menu = create_sub_menu_with_mnemonic( menu, "E_xpand Selection" );
+// auto convert_menu = create_sub_menu_with_mnemonic( menu, "E_xpand Selection" );
// if ( g_Layout_enableDetachableMenus.m_value ) {
// menu_tearoff( convert_menu );
// }
return edit_menu_item;
}
-void fill_view_xy_top_menu( GtkMenu* menu ){
+void fill_view_xy_top_menu( ui::Menu menu ){
create_check_menu_item_with_mnemonic( menu, "XY (Top) View", "ToggleView" );
}
-void fill_view_yz_side_menu( GtkMenu* menu ){
+void fill_view_yz_side_menu( ui::Menu menu ){
create_check_menu_item_with_mnemonic( menu, "YZ (Side) View", "ToggleSideView" );
}
-void fill_view_xz_front_menu( GtkMenu* menu ){
+void fill_view_xz_front_menu( ui::Menu menu ){
create_check_menu_item_with_mnemonic( menu, "XZ (Front) View", "ToggleFrontView" );
}
-GtkWidget* g_toggle_z_item = 0;
-GtkWidget* g_toggle_console_item = 0;
-GtkWidget* g_toggle_entity_item = 0;
-GtkWidget* g_toggle_entitylist_item = 0;
+ui::Widget g_toggle_z_item{ui::null};
+ui::Widget g_toggle_console_item{ui::null};
+ui::Widget g_toggle_entity_item{ui::null};
+ui::Widget g_toggle_entitylist_item{ui::null};
-GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){
+ui::MenuItem create_view_menu( MainFrame::EViewStyle style ){
// View menu
- GtkMenuItem* view_menu_item = new_sub_menu_item_with_mnemonic( "Vie_w" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( view_menu_item ) );
+ auto view_menu_item = new_sub_menu_item_with_mnemonic( "Vie_w" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( view_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
menu_separator( menu );
{
- GtkMenu* camera_menu = create_sub_menu_with_mnemonic( menu, "Camera" );
+ auto camera_menu = create_sub_menu_with_mnemonic( menu, "Camera" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( camera_menu );
}
}
menu_separator( menu );
{
- GtkMenu* orthographic_menu = create_sub_menu_with_mnemonic( menu, "Orthographic" );
+ auto orthographic_menu = create_sub_menu_with_mnemonic( menu, "Orthographic" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( orthographic_menu );
}
menu_separator( menu );
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Show" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Show" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
}
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Filter" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Filter" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
}
menu_separator( menu );
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Region" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Region" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
return view_menu_item;
}
-GtkMenuItem* create_selection_menu(){
+ui::MenuItem create_selection_menu(){
// Selection menu
- GtkMenuItem* selection_menu_item = new_sub_menu_item_with_mnemonic( "M_odify" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( selection_menu_item ) );
+ auto selection_menu_item = new_sub_menu_item_with_mnemonic( "M_odify" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( selection_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Components" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Components" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
menu_separator( menu );
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Nudge" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Nudge" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
create_menu_item_with_mnemonic( menu_in_menu, "Nudge Down", "SelectNudgeDown" );
}
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Rotate" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Rotate" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
create_menu_item_with_mnemonic( menu_in_menu, "Rotate Z", "RotateSelectionZ" );
}
{
- GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Flip" );
+ auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "Flip" );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu_in_menu );
}
return selection_menu_item;
}
-GtkMenuItem* create_bsp_menu(){
+ui::MenuItem create_bsp_menu(){
// BSP menu
- GtkMenuItem* bsp_menu_item = new_sub_menu_item_with_mnemonic( "_Build" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( bsp_menu_item ) );
+ auto bsp_menu_item = new_sub_menu_item_with_mnemonic( "_Build" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( bsp_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
return bsp_menu_item;
}
-GtkMenuItem* create_grid_menu(){
+ui::MenuItem create_grid_menu(){
// Grid menu
- GtkMenuItem* grid_menu_item = new_sub_menu_item_with_mnemonic( "_Grid" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( grid_menu_item ) );
+ auto grid_menu_item = new_sub_menu_item_with_mnemonic( "_Grid" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( grid_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
return grid_menu_item;
}
-GtkMenuItem* create_misc_menu(){
+ui::MenuItem create_misc_menu(){
// Misc menu
- GtkMenuItem* misc_menu_item = new_sub_menu_item_with_mnemonic( "M_isc" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( misc_menu_item ) );
+ auto misc_menu_item = new_sub_menu_item_with_mnemonic( "M_isc" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( misc_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
#if 0
- create_menu_item_with_mnemonic( menu, "_Benchmark", FreeCaller<GlobalCamera_Benchmark>() );
+ create_menu_item_with_mnemonic( menu, "_Benchmark", makeCallbackF(GlobalCamera_Benchmark) );
#endif
- gtk_container_add( GTK_CONTAINER( menu ), GTK_WIDGET( create_colours_menu() ) );
+ menu.add(create_colours_menu());
create_menu_item_with_mnemonic( menu, "Find brush...", "FindBrush" );
create_menu_item_with_mnemonic( menu, "Map Info...", "MapInfo" );
// http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394
-// create_menu_item_with_mnemonic(menu, "_Print XY View", FreeCaller<WXY_Print>());
- create_menu_item_with_mnemonic( menu, "_Background select", FreeCaller<WXY_BackgroundSelect>() );
+// create_menu_item_with_mnemonic(menu, "_Print XY View", FreeCaller<void(), WXY_Print>());
+ create_menu_item_with_mnemonic( menu, "_Background select", makeCallbackF(WXY_BackgroundSelect) );
return misc_menu_item;
}
-GtkMenuItem* create_entity_menu(){
+ui::MenuItem create_entity_menu(){
// Brush menu
- GtkMenuItem* entity_menu_item = new_sub_menu_item_with_mnemonic( "E_ntity" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( entity_menu_item ) );
+ auto entity_menu_item = new_sub_menu_item_with_mnemonic( "E_ntity" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( entity_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
return entity_menu_item;
}
-GtkMenuItem* create_brush_menu(){
+ui::MenuItem create_brush_menu(){
// Brush menu
- GtkMenuItem* brush_menu_item = new_sub_menu_item_with_mnemonic( "B_rush" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( brush_menu_item ) );
+ auto brush_menu_item = new_sub_menu_item_with_mnemonic( "B_rush" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( brush_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
return brush_menu_item;
}
-GtkMenuItem* create_patch_menu(){
+ui::MenuItem create_patch_menu(){
// Curve menu
- GtkMenuItem* patch_menu_item = new_sub_menu_item_with_mnemonic( "_Curve" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( patch_menu_item ) );
+ auto patch_menu_item = new_sub_menu_item_with_mnemonic( "_Curve" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( patch_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
return patch_menu_item;
}
-GtkMenuItem* create_help_menu(){
+ui::MenuItem create_help_menu(){
// Help menu
- GtkMenuItem* help_menu_item = new_sub_menu_item_with_mnemonic( "_Help" );
- GtkMenu* menu = GTK_MENU( gtk_menu_item_get_submenu( help_menu_item ) );
+ auto help_menu_item = new_sub_menu_item_with_mnemonic( "_Help" );
+ auto menu = ui::Menu::from( gtk_menu_item_get_submenu( help_menu_item ) );
if ( g_Layout_enableDetachableMenus.m_value ) {
menu_tearoff( menu );
}
// it will take care of hooking the Sys_OpenURL calls etc.
create_game_help_menu( menu );
-// create_menu_item_with_mnemonic( menu, "Bug report", FreeCaller<OpenBugReportURL>() );
- create_menu_item_with_mnemonic( menu, "Shortcuts list", FreeCaller<DoCommandListDlg>() );
- create_menu_item_with_mnemonic( menu, "_About", FreeCaller<DoAbout>() );
+ create_menu_item_with_mnemonic( menu, "Bug report", makeCallbackF(OpenBugReportURL) );
+ create_menu_item_with_mnemonic( menu, "Shortcuts list", makeCallbackF(DoCommandListDlg) );
+ create_menu_item_with_mnemonic( menu, "_About", makeCallbackF(DoAbout) );
return help_menu_item;
}
-GtkMenuBar* create_main_menu( MainFrame::EViewStyle style ){
- GtkMenuBar* menu_bar = GTK_MENU_BAR( gtk_menu_bar_new() );
- gtk_widget_show( GTK_WIDGET( menu_bar ) );
+ui::MenuBar create_main_menu( MainFrame::EViewStyle style ){
+ auto menu_bar = ui::MenuBar::from( gtk_menu_bar_new() );
+ menu_bar.show();
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_file_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_edit_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_view_menu( style ) ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_selection_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_bsp_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_grid_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_misc_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_entity_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_brush_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_patch_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_plugins_menu() ) );
- gtk_container_add( GTK_CONTAINER( menu_bar ), GTK_WIDGET( create_help_menu() ) );
+ menu_bar.add(create_file_menu());
+ menu_bar.add(create_edit_menu());
+ menu_bar.add(create_view_menu(style));
+ menu_bar.add(create_selection_menu());
+ menu_bar.add(create_bsp_menu());
+ menu_bar.add(create_grid_menu());
+ menu_bar.add(create_misc_menu());
+ menu_bar.add(create_entity_menu());
+ menu_bar.add(create_brush_menu());
+ menu_bar.add(create_patch_menu());
+ menu_bar.add(create_plugins_menu());
+ menu_bar.add(create_help_menu());
return menu_bar;
}
void Patch_registerShortcuts(){
command_connect_accelerator( "InvertCurveTextureX" );
command_connect_accelerator( "InvertCurveTextureY" );
- command_connect_accelerator( "IncPatchColumn" );
- command_connect_accelerator( "IncPatchRow" );
- command_connect_accelerator( "DecPatchColumn" );
- command_connect_accelerator( "DecPatchRow" );
+ command_connect_accelerator( "PatchInsertInsertColumn" );
+ command_connect_accelerator( "PatchInsertInsertRow" );
+ command_connect_accelerator( "PatchDeleteLastColumn" );
+ command_connect_accelerator( "PatchDeleteLastRow" );
command_connect_accelerator( "NaturalizePatch" );
//command_connect_accelerator("CapCurrentCurve");
}
SelectByType_registerShortcuts();
}
-void File_constructToolbar( GtkToolbar* toolbar ){
- toolbar_append_button( toolbar, "Open an existing map (CTRL + O)", "file_open.bmp", "OpenMap" );
- toolbar_append_button( toolbar, "Save the active map (CTRL + S)", "file_save.bmp", "SaveMap" );
+void File_constructToolbar( ui::Toolbar toolbar ){
+ toolbar_append_button( toolbar, "Open an existing map (CTRL + O)", "file_open.png", "OpenMap" );
+ toolbar_append_button( toolbar, "Save the active map (CTRL + S)", "file_save.png", "SaveMap" );
}
-void UndoRedo_constructToolbar( GtkToolbar* toolbar ){
- toolbar_append_button( toolbar, "Undo (CTRL + Z)", "undo.bmp", "Undo" );
- toolbar_append_button( toolbar, "Redo (CTRL + Y)", "redo.bmp", "Redo" );
+void UndoRedo_constructToolbar( ui::Toolbar toolbar ){
+ toolbar_append_button( toolbar, "Undo (CTRL + Z)", "undo.png", "Undo" );
+ toolbar_append_button( toolbar, "Redo (CTRL + Y)", "redo.png", "Redo" );
}
-void RotateFlip_constructToolbar( GtkToolbar* toolbar ){
- toolbar_append_button( toolbar, "x-axis Flip", "brush_flipx.bmp", "MirrorSelectionX" );
- toolbar_append_button( toolbar, "x-axis Rotate", "brush_rotatex.bmp", "RotateSelectionX" );
- toolbar_append_button( toolbar, "y-axis Flip", "brush_flipy.bmp", "MirrorSelectionY" );
- toolbar_append_button( toolbar, "y-axis Rotate", "brush_rotatey.bmp", "RotateSelectionY" );
- toolbar_append_button( toolbar, "z-axis Flip", "brush_flipz.bmp", "MirrorSelectionZ" );
- toolbar_append_button( toolbar, "z-axis Rotate", "brush_rotatez.bmp", "RotateSelectionZ" );
+void RotateFlip_constructToolbar( ui::Toolbar toolbar ){
+ toolbar_append_button( toolbar, "x-axis Flip", "brush_flipx.png", "MirrorSelectionX" );
+ toolbar_append_button( toolbar, "x-axis Rotate", "brush_rotatex.png", "RotateSelectionX" );
+ toolbar_append_button( toolbar, "y-axis Flip", "brush_flipy.png", "MirrorSelectionY" );
+ toolbar_append_button( toolbar, "y-axis Rotate", "brush_rotatey.png", "RotateSelectionY" );
+ toolbar_append_button( toolbar, "z-axis Flip", "brush_flipz.png", "MirrorSelectionZ" );
+ toolbar_append_button( toolbar, "z-axis Rotate", "brush_rotatez.png", "RotateSelectionZ" );
}
-void Select_constructToolbar( GtkToolbar* toolbar ){
- toolbar_append_button( toolbar, "Select touching", "selection_selecttouching.bmp", "SelectTouching" );
- toolbar_append_button( toolbar, "Select inside", "selection_selectinside.bmp", "SelectInside" );
+void Select_constructToolbar( ui::Toolbar toolbar ){
+ toolbar_append_button( toolbar, "Select touching", "selection_selecttouching.png", "SelectTouching" );
+ toolbar_append_button( toolbar, "Select inside", "selection_selectinside.png", "SelectInside" );
}
-void CSG_constructToolbar( GtkToolbar* toolbar ){
- toolbar_append_button( toolbar, "CSG Subtract (SHIFT + U)", "selection_csgsubtract.bmp", "CSGSubtract" );
- toolbar_append_button( toolbar, "CSG Merge (CTRL + U)", "selection_csgmerge.bmp", "CSGMerge" );
- toolbar_append_button( toolbar, "Hollow", "selection_makehollow.bmp", "CSGHollow" );
+void CSG_constructToolbar( ui::Toolbar toolbar ){
+ toolbar_append_button( toolbar, "CSG Subtract (SHIFT + U)", "selection_csgsubtract.png", "CSGSubtract" );
+ toolbar_append_button( toolbar, "CSG Merge (CTRL + U)", "selection_csgmerge.png", "CSGMerge" );
+ toolbar_append_button( toolbar, "Make Hollow", "selection_makehollow.png", "CSGMakeHollow" );
+ toolbar_append_button( toolbar, "Make Room", "selection_makeroom.png", "CSGMakeRoom" );
}
-void ComponentModes_constructToolbar( GtkToolbar* toolbar ){
- toolbar_append_toggle_button( toolbar, "Select Vertices (V)", "modify_vertices.bmp", "DragVertices" );
- toolbar_append_toggle_button( toolbar, "Select Edges (E)", "modify_edges.bmp", "DragEdges" );
- toolbar_append_toggle_button( toolbar, "Select Faces (F)", "modify_faces.bmp", "DragFaces" );
+void ComponentModes_constructToolbar( ui::Toolbar toolbar ){
+ toolbar_append_toggle_button( toolbar, "Select Vertices (V)", "modify_vertices.png", "DragVertices" );
+ toolbar_append_toggle_button( toolbar, "Select Edges (E)", "modify_edges.png", "DragEdges" );
+ toolbar_append_toggle_button( toolbar, "Select Faces (F)", "modify_faces.png", "DragFaces" );
}
-void Clipper_constructToolbar( GtkToolbar* toolbar ){
+void Clipper_constructToolbar( ui::Toolbar toolbar ){
- toolbar_append_toggle_button( toolbar, "Clipper (X)", "view_clipper.bmp", "ToggleClipper" );
+ toolbar_append_toggle_button( toolbar, "Clipper (X)", "view_clipper.png", "ToggleClipper" );
}
-void XYWnd_constructToolbar( GtkToolbar* toolbar ){
- toolbar_append_button( toolbar, "Change views", "view_change.bmp", "NextView" );
+void XYWnd_constructToolbar( ui::Toolbar toolbar ){
+ toolbar_append_button( toolbar, "Change views", "view_change.png", "NextView" );
}
-void Manipulators_constructToolbar( GtkToolbar* toolbar ){
- toolbar_append_toggle_button( toolbar, "Translate (W)", "select_mousetranslate.bmp", "MouseTranslate" );
- toolbar_append_toggle_button( toolbar, "Rotate (R)", "select_mouserotate.bmp", "MouseRotate" );
- toolbar_append_toggle_button( toolbar, "Scale", "select_mousescale.bmp", "MouseScale" );
- toolbar_append_toggle_button( toolbar, "Resize (Q)", "select_mouseresize.bmp", "MouseDrag" );
+void Manipulators_constructToolbar( ui::Toolbar toolbar ){
+ toolbar_append_toggle_button( toolbar, "Translate (W)", "select_mousetranslate.png", "MouseTranslate" );
+ toolbar_append_toggle_button( toolbar, "Rotate (R)", "select_mouserotate.png", "MouseRotate" );
+ toolbar_append_toggle_button( toolbar, "Scale", "select_mousescale.png", "MouseScale" );
+ toolbar_append_toggle_button( toolbar, "Resize (Q)", "select_mouseresize.png", "MouseDrag" );
Clipper_constructToolbar( toolbar );
}
-GtkToolbar* create_main_toolbar( MainFrame::EViewStyle style ){
- GtkToolbar* toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
- gtk_toolbar_set_orientation( toolbar, GTK_ORIENTATION_HORIZONTAL );
+ui::Toolbar create_main_toolbar( MainFrame::EViewStyle style ){
+ auto toolbar = ui::Toolbar::from( gtk_toolbar_new() );
+ gtk_orientable_set_orientation( GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL );
gtk_toolbar_set_style( toolbar, GTK_TOOLBAR_ICONS );
- gtk_widget_show( GTK_WIDGET( toolbar ) );
+ toolbar.show();
+
+ auto space = [&]() {
+ auto btn = ui::ToolItem::from(gtk_separator_tool_item_new());
+ btn.show();
+ toolbar.add(btn);
+ };
File_constructToolbar( toolbar );
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+ space();
UndoRedo_constructToolbar( toolbar );
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+ space();
RotateFlip_constructToolbar( toolbar );
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+ space();
Select_constructToolbar( toolbar );
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+ space();
CSG_constructToolbar( toolbar );
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+ space();
ComponentModes_constructToolbar( toolbar );
if ( style == MainFrame::eRegular || style == MainFrame::eRegularLeft || style == MainFrame::eFloating ) {
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+ space();
XYWnd_constructToolbar( toolbar );
}
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+ space();
CamWnd_constructToolbar( toolbar );
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+ space();
Manipulators_constructToolbar( toolbar );
if ( g_Layout_enablePatchToolbar.m_value ) {
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+ space();
Patch_constructToolbar( toolbar );
}
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+ space();
- toolbar_append_toggle_button( toolbar, "Texture Lock (SHIFT + T)", "texture_lock.bmp", "TogTexLock" );
+ toolbar_append_toggle_button( toolbar, "Texture Lock (SHIFT +T)", "texture_lock.png", "TogTexLock" );
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
+ space();
- GtkButton* g_view_entities_button = toolbar_append_button( toolbar, "Entities (N)", "entities.bmp", "ToggleEntityInspector" );
- GtkButton* g_view_console_button = toolbar_append_button( toolbar, "Console (O)", "console.bmp", "ToggleConsole" );
- GtkButton* g_view_textures_button = toolbar_append_button( toolbar, "Texture Browser (T)", "texture_browser.bmp", "ToggleTextures" );
+ /*auto g_view_entities_button =*/ toolbar_append_button( toolbar, "Entities (N)", "entities.png", "ToggleEntityInspector" );
+ auto g_view_console_button = toolbar_append_button( toolbar, "Console (O)", "console.png", "ToggleConsole" );
+ auto g_view_textures_button = toolbar_append_button( toolbar, "Texture Browser (T)", "texture_browser.png", "ToggleTextures" );
// TODO: call light inspector
- //GtkButton* g_view_lightinspector_button = toolbar_append_button(toolbar, "Light Inspector", "lightinspector.bmp", "ToggleLightInspector");
+ //GtkButton* g_view_lightinspector_button = toolbar_append_button(toolbar, "Light Inspector", "lightinspector.png", "ToggleLightInspector");
- gtk_toolbar_append_space( GTK_TOOLBAR( toolbar ) );
- GtkButton* g_refresh_models_button = toolbar_append_button( toolbar, "Refresh Models", "refresh_models.bmp", "RefreshReferences" );
+ space();
+ /*auto g_refresh_models_button =*/ toolbar_append_button( toolbar, "Refresh Models", "refresh_models.png", "RefreshReferences" );
// disable the console and texture button in the regular layouts
if ( style == MainFrame::eRegular || style == MainFrame::eRegularLeft ) {
- gtk_widget_set_sensitive( GTK_WIDGET( g_view_console_button ), FALSE );
- gtk_widget_set_sensitive( GTK_WIDGET( g_view_textures_button ), FALSE );
+ gtk_widget_set_sensitive( g_view_console_button , FALSE );
+ gtk_widget_set_sensitive( g_view_textures_button , FALSE );
}
return toolbar;
}
-GtkWidget* create_main_statusbar( GtkWidget *pStatusLabel[c_count_status] ){
- GtkTable* table = GTK_TABLE( gtk_table_new( 1, c_count_status, FALSE ) );
- gtk_widget_show( GTK_WIDGET( table ) );
+ui::Widget create_main_statusbar( ui::Widget pStatusLabel[c_count_status] ){
+ auto table = ui::Table( 1, c_count_status, FALSE );
+ table.show();
{
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Label" ) );
+ auto label = ui::Label( "Label" );
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
gtk_misc_set_padding( GTK_MISC( label ), 4, 2 );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_table_attach_defaults( table, GTK_WIDGET( label ), 0, 1, 0, 1 );
- pStatusLabel[c_command_status] = GTK_WIDGET( label );
+ label.show();
+ table.attach(label, {0, 1, 0, 1});
+ pStatusLabel[c_command_status] = ui::Widget(label );
}
- for ( int i = 1; i < c_count_status; ++i )
+ for (unsigned int i = 1; (int) i < c_count_status; ++i)
{
- GtkFrame* frame = GTK_FRAME( gtk_frame_new( 0 ) );
- gtk_widget_show( GTK_WIDGET( frame ) );
- gtk_table_attach_defaults( table, GTK_WIDGET( frame ), i, i + 1, 0, 1 );
+ auto frame = ui::Frame();
+ frame.show();
+ table.attach(frame, {i, i + 1, 0, 1});
gtk_frame_set_shadow_type( frame, GTK_SHADOW_IN );
- GtkLabel* label = GTK_LABEL( gtk_label_new( "Label" ) );
+ auto label = ui::Label( "Label" );
gtk_label_set_ellipsize( label, PANGO_ELLIPSIZE_END );
gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 );
gtk_misc_set_padding( GTK_MISC( label ), 4, 2 );
- gtk_widget_show( GTK_WIDGET( label ) );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( label ) );
- pStatusLabel[i] = GTK_WIDGET( label );
+ label.show();
+ frame.add(label);
+ pStatusLabel[i] = ui::Widget(label );
}
- return GTK_WIDGET( table );
+ return ui::Widget(table );
}
#if 0
{
const char* m_name;
-static gboolean frame_event( GtkWidget *widget, GdkEvent* event, WindowFocusPrinter* self ){
+static gboolean frame_event( ui::Widget widget, GdkEvent* event, WindowFocusPrinter* self ){
globalOutputStream() << self->m_name << " frame_event\n";
return FALSE;
}
-static gboolean keys_changed( GtkWidget *widget, WindowFocusPrinter* self ){
+static gboolean keys_changed( ui::Widget widget, WindowFocusPrinter* self ){
globalOutputStream() << self->m_name << " keys_changed\n";
return FALSE;
}
-static gboolean notify( GtkWindow* window, gpointer dummy, WindowFocusPrinter* self ){
+static gboolean notify( ui::Window window, gpointer dummy, WindowFocusPrinter* self ){
if ( gtk_window_is_active( window ) ) {
globalOutputStream() << self->m_name << " takes toplevel focus\n";
}
public:
WindowFocusPrinter( const char* name ) : m_name( name ){
}
-void connect( GtkWindow* toplevel_window ){
- g_signal_connect( G_OBJECT( toplevel_window ), "notify::has_toplevel_focus", G_CALLBACK( notify ), this );
- g_signal_connect( G_OBJECT( toplevel_window ), "notify::is_active", G_CALLBACK( notify ), this );
- g_signal_connect( G_OBJECT( toplevel_window ), "keys_changed", G_CALLBACK( keys_changed ), this );
- g_signal_connect( G_OBJECT( toplevel_window ), "frame_event", G_CALLBACK( frame_event ), this );
+void connect( ui::Window toplevel_window ){
+ toplevel_window.connect( "notify::has_toplevel_focus", G_CALLBACK( notify ), this );
+ toplevel_window.connect( "notify::is_active", G_CALLBACK( notify ), this );
+ toplevel_window.connect( "keys_changed", G_CALLBACK( keys_changed ), this );
+ toplevel_window.connect( "frame_event", G_CALLBACK( frame_event ), this );
}
};
class MainWindowActive
{
-static gboolean notify( GtkWindow* window, gpointer dummy, MainWindowActive* self ){
- if ( g_wait.m_window != 0 && gtk_window_is_active( window ) && !GTK_WIDGET_VISIBLE( g_wait.m_window ) ) {
- gtk_widget_show( GTK_WIDGET( g_wait.m_window ) );
+static gboolean notify( ui::Window window, gpointer dummy, MainWindowActive* self ){
+ if ( g_wait.m_window && gtk_window_is_active( window ) && !g_wait.m_window.visible() ) {
+ g_wait.m_window.show();
}
return FALSE;
}
+
public:
-void connect( GtkWindow* toplevel_window ){
- g_signal_connect( G_OBJECT( toplevel_window ), "notify::is-active", G_CALLBACK( notify ), this );
+void connect( ui::Window toplevel_window ){
+ toplevel_window.connect( "notify::is-active", G_CALLBACK( notify ), this );
}
};
MainFrame* g_pParentWnd = 0;
-GtkWindow* MainFrame_getWindow(){
- if ( g_pParentWnd == 0 ) {
- return 0;
- }
- return g_pParentWnd->m_window;
+ui::Window MainFrame_getWindow()
+{
+ return g_pParentWnd ? g_pParentWnd->m_window : ui::Window{ui::null};
}
-std::vector<GtkWidget*> g_floating_windows;
+std::vector<ui::Widget> g_floating_windows;
-MainFrame::MainFrame() : m_window( 0 ), m_idleRedrawStatusText( RedrawStatusTextCaller( *this ) ){
+MainFrame::MainFrame() : m_idleRedrawStatusText( RedrawStatusTextCaller( *this ) ){
m_pXYWnd = 0;
m_pCamWnd = 0;
m_pZWnd = 0;
m_pXZWnd = 0;
m_pActiveXY = 0;
- for ( int n = 0; n < c_count_status; n++ )
- {
- m_pStatusLabel[n] = 0;
+ for (auto &n : m_pStatusLabel) {
+ n = NULL;
}
m_bSleeping = false;
MainFrame::~MainFrame(){
SaveWindowInfo();
- gtk_widget_hide( GTK_WIDGET( m_window ) );
+ m_window.hide();
Shutdown();
- for ( std::vector<GtkWidget*>::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i )
+ for ( std::vector<ui::Widget>::iterator i = g_floating_windows.begin(); i != g_floating_windows.end(); ++i )
{
- gtk_widget_destroy( *i );
+ i->destroy();
}
- gtk_widget_destroy( GTK_WIDGET( m_window ) );
+ m_window.destroy();
}
void MainFrame::SetActiveXY( XYWnd* p ){
#endif
}
-#ifdef _DEBUG
+#if GDEF_DEBUG
//#define DBG_SLEEP
#endif
}
-GtkWindow* create_splash(){
- GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) );
- gtk_window_set_decorated( window, FALSE );
- gtk_window_set_resizable( window, FALSE );
- gtk_window_set_modal( window, TRUE );
+ui::Window create_splash(){
+ auto window = ui::Window( ui::window_type::TOP );
+ gtk_window_set_decorated(window, false);
+ gtk_window_set_resizable(window, false);
+ gtk_window_set_modal(window, true);
gtk_window_set_default_size( window, -1, -1 );
gtk_window_set_position( window, GTK_WIN_POS_CENTER );
- gtk_container_set_border_width( GTK_CONTAINER( window ), 0 );
+ gtk_container_set_border_width(window, 0);
- GtkImage* image = new_local_image( "splash.bmp" );
- gtk_widget_show( GTK_WIDGET( image ) );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( image ) );
+ auto image = new_local_image( "splash.png" );
+ image.show();
+ window.add(image);
- gtk_widget_set_size_request( GTK_WIDGET( window ), -1, -1 );
- gtk_widget_show( GTK_WIDGET( window ) );
+ window.dimensions(-1, -1);
+ window.show();
return window;
}
-static GtkWindow *splash_screen = 0;
+static ui::Window splash_screen{ui::null};
void show_splash(){
splash_screen = create_splash();
- process_gui();
+ ui::process();
}
void hide_splash(){
- gtk_widget_destroy( GTK_WIDGET( splash_screen ) );
+ splash_screen.destroy();
}
WindowPositionTracker g_posCamWnd;
WindowPositionTracker g_posXZWnd;
WindowPositionTracker g_posYZWnd;
-static gint mainframe_delete( GtkWidget *widget, GdkEvent *event, gpointer data ){
+static gint mainframe_delete( ui::Widget widget, GdkEvent *event, gpointer data ){
if ( ConfirmModified( "Exit Radiant" ) ) {
gtk_main_quit();
}
}
void MainFrame::Create(){
- GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) );
+ ui::Window window = ui::Window( ui::window_type::TOP );
GlobalWindowObservers_connectTopLevel( window );
gtk_window_set_transient_for( splash_screen, window );
-#if !defined( WIN32 )
+#if !GDEF_OS_WINDOWS
{
- GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask( "bitmaps/icon.bmp" );
+ GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask( "bitmaps/icon.png" );
if ( pixbuf != 0 ) {
gtk_window_set_icon( window, pixbuf );
- gdk_pixbuf_unref( pixbuf );
+ g_object_unref( pixbuf );
}
}
#endif
- gtk_widget_add_events( GTK_WIDGET( window ), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK );
- g_signal_connect( G_OBJECT( window ), "delete_event", G_CALLBACK( mainframe_delete ), this );
+ gtk_widget_add_events( window , GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK );
+ window.connect( "delete_event", G_CALLBACK( mainframe_delete ), this );
m_position_tracker.connect( window );
g_MainWindowActive.connect( window );
- GetPlugInMgr().Init( GTK_WIDGET( window ) );
+ GetPlugInMgr().Init( window );
- GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
- gtk_container_add( GTK_CONTAINER( window ), vbox );
- gtk_widget_show( vbox );
+ auto vbox = ui::VBox( FALSE, 0 );
+ window.add(vbox);
+ vbox.show();
global_accel_connect_window( window );
register_shortcuts();
- GtkMenuBar* main_menu = create_main_menu( CurrentStyle() );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_menu ), FALSE, FALSE, 0 );
+ auto main_menu = create_main_menu( CurrentStyle() );
+ vbox.pack_start( main_menu, FALSE, FALSE, 0 );
- GtkToolbar* main_toolbar = create_main_toolbar( CurrentStyle() );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( main_toolbar ), FALSE, FALSE, 0 );
+ auto main_toolbar = create_main_toolbar( CurrentStyle() );
+ vbox.pack_start( main_toolbar, FALSE, FALSE, 0 );
- GtkToolbar* plugin_toolbar = create_plugin_toolbar();
+ auto plugin_toolbar = create_plugin_toolbar();
if ( !g_Layout_enablePluginToolbar.m_value ) {
- gtk_widget_hide( GTK_WIDGET( plugin_toolbar ) );
+ plugin_toolbar.hide();
}
- gtk_toolbar_append_space( GTK_TOOLBAR( plugin_toolbar ) );
- gtk_toolbar_append_space( GTK_TOOLBAR( plugin_toolbar ) );
+
+ if ( g_Layout_enableFilterToolbar.m_value ) {
- toolbar_append_toggle_button( plugin_toolbar, "Patches (CTRL + P)", "patch_wireframe.bmp", "FilterPatches" );
- gtk_toolbar_append_space( GTK_TOOLBAR( plugin_toolbar ) );
++ auto space = [&]() {
++ auto btn = gtk_separator_tool_item_new();
++ gtk_widget_show(GTK_WIDGET(btn));
++ gtk_container_add(GTK_CONTAINER(plugin_toolbar), GTK_WIDGET(btn));
++ };
++
++ space();
+ toolbar_append_toggle_button( plugin_toolbar, "World (ALT + 1)", "f-world.bmp", "FilterWorldBrushes" );
+ toolbar_append_toggle_button( plugin_toolbar, "Details (CTRL + D)", "f-details.bmp", "FilterDetails" );
+ toolbar_append_toggle_button( plugin_toolbar, "Structural (CTRL + SHIFT + D)", "f-structural.bmp", "FilterStructural" );
- gtk_toolbar_append_space( GTK_TOOLBAR( plugin_toolbar ) );
++ toolbar_append_toggle_button( plugin_toolbar, "Patches (CTRL + P)", "patch_wireframe.png", "FilterPatches" );
++ space();
+ toolbar_append_toggle_button( plugin_toolbar, "Areaportals (ALT + 3)", "f-areaportal.bmp", "FilterAreaportals" );
+ toolbar_append_toggle_button( plugin_toolbar, "Translucent (ALT + 4)", "f-translucent.bmp", "FilterTranslucent" );
+ toolbar_append_toggle_button( plugin_toolbar, "Liquids (ALT + 5)", "f-liquids.bmp", "FilterLiquids" );
+ toolbar_append_toggle_button( plugin_toolbar, "Caulk (ALT + 6)", "f-caulk.bmp", "FilterCaulk" );
+ toolbar_append_toggle_button( plugin_toolbar, "Clips (ALT + 7)", "f-clip.bmp", "FilterClips" );
+ toolbar_append_toggle_button( plugin_toolbar, "HintsSkips (CTRL + H)", "f-hint.bmp", "FilterHintsSkips" );
+ //toolbar_append_toggle_button( plugin_toolbar, "Paths (ALT + 8)", "texture_lock.bmp", "FilterPaths" );
- toolbar_append_toggle_button( plugin_toolbar, "Lights (ALT + 0)", "lightinspector.bmp", "FilterLights" );
++ space();
+ toolbar_append_toggle_button( plugin_toolbar, "Entities (ALT + 2)", "f-entities.bmp", "FilterEntities" );
- gtk_toolbar_append_space( GTK_TOOLBAR( plugin_toolbar ) );
++ toolbar_append_toggle_button( plugin_toolbar, "Lights (ALT + 0)", "lightinspector.png", "FilterLights" );
+ toolbar_append_toggle_button( plugin_toolbar, "Models (SHIFT + M)", "f-models.bmp", "FilterModels" );
+ toolbar_append_toggle_button( plugin_toolbar, "Triggers (CTRL + SHIFT + T)", "f-triggers.bmp", "FilterTriggers" );
+ toolbar_append_toggle_button( plugin_toolbar, "Decals (SHIFT + D)", "f-decals.bmp", "FilterDecals" );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( plugin_toolbar ), FALSE, FALSE, 0 );
++ space();
+ toolbar_append_button( plugin_toolbar, "InvertFilters", "f-invert.bmp", "InvertFilters" );
+ toolbar_append_button( plugin_toolbar, "ResetFilters", "f-reset.bmp", "ResetFilters" );
+ }
+ vbox.pack_start( plugin_toolbar, FALSE, FALSE, 0 );
- GtkWidget* main_statusbar = create_main_statusbar( m_pStatusLabel );
- gtk_box_pack_end( GTK_BOX( vbox ), main_statusbar, FALSE, TRUE, 2 );
+ ui::Widget main_statusbar = create_main_statusbar(reinterpret_cast<ui::Widget *>(m_pStatusLabel));
+ vbox.pack_end(main_statusbar, FALSE, TRUE, 2);
GroupDialog_constructWindow( window );
g_page_entity = GroupDialog_addPage( "Entities", EntityInspector_constructWindow( GroupDialog_getWindow() ), RawStringExportCaller( "Entities" ) );
g_page_console = GroupDialog_addPage( "Console", Console_constructWindow( GroupDialog_getWindow() ), RawStringExportCaller( "Console" ) );
}
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
if ( g_multimon_globals.m_bStartOnPrimMon ) {
PositionWindowOnPrimaryScreen( g_layout_globals.m_position );
window_set_position( window, g_layout_globals.m_position );
m_window = window;
- gtk_widget_show( GTK_WIDGET( window ) );
+ window.show();
if ( CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft ) {
{
- GtkWidget* vsplit = gtk_vpaned_new();
+ ui::Widget vsplit = ui::VPaned(ui::New);
m_vSplit = vsplit;
- gtk_box_pack_start( GTK_BOX( vbox ), vsplit, TRUE, TRUE, 0 );
- gtk_widget_show( vsplit );
+ vbox.pack_start( vsplit, TRUE, TRUE, 0 );
+ vsplit.show();
// console
- GtkWidget* console_window = Console_constructWindow( window );
+ ui::Widget console_window = Console_constructWindow( window );
gtk_paned_pack2( GTK_PANED( vsplit ), console_window, FALSE, TRUE );
{
- GtkWidget* hsplit = gtk_hpaned_new();
- gtk_widget_show( hsplit );
+ ui::Widget hsplit = ui::HPaned(ui::New);
+ hsplit.show();
m_hSplit = hsplit;
gtk_paned_add1( GTK_PANED( vsplit ), hsplit );
// xy
m_pXYWnd = new XYWnd();
m_pXYWnd->SetViewType( XY );
- GtkWidget* xy_window = GTK_WIDGET( create_framed_widget( m_pXYWnd->GetWidget() ) );
+ ui::Widget xy_window = ui::Widget(create_framed_widget( m_pXYWnd->GetWidget( ) ));
{
- GtkWidget* vsplit2 = gtk_vpaned_new();
- gtk_widget_show( vsplit2 );
+ ui::Widget vsplit2 = ui::VPaned(ui::New);
+ vsplit2.show();
m_vSplit2 = vsplit2;
if ( CurrentStyle() == eRegular ) {
m_pCamWnd = NewCamWnd();
GlobalCamera_setCamWnd( *m_pCamWnd );
CamWnd_setParent( *m_pCamWnd, window );
- GtkFrame* camera_window = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) );
+ auto camera_window = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) );
- gtk_paned_add1( GTK_PANED( vsplit2 ), GTK_WIDGET( camera_window ) );
+ gtk_paned_add1( GTK_PANED( vsplit2 ), camera_window );
// textures
- GtkFrame* texture_window = create_framed_widget( TextureBrowser_constructWindow( window ) );
+ auto texture_window = create_framed_widget( TextureBrowser_constructWindow( window ) );
- gtk_paned_add2( GTK_PANED( vsplit2 ), GTK_WIDGET( texture_window ) );
+ gtk_paned_add2( GTK_PANED( vsplit2 ), texture_window );
}
}
}
}
else if ( CurrentStyle() == eFloating ) {
{
- GtkWindow* window = create_persistent_floating_window( "Camera", m_window );
+ ui::Window window = ui::Window(create_persistent_floating_window( "Camera", m_window ));
global_accel_connect_window( window );
g_posCamWnd.connect( window );
- gtk_widget_show( GTK_WIDGET( window ) );
+ window.show();
m_pCamWnd = NewCamWnd();
GlobalCamera_setCamWnd( *m_pCamWnd );
{
- GtkFrame* frame = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) );
+ auto frame = create_framed_widget( CamWnd_getWidget( *m_pCamWnd ) );
+ window.add(frame);
}
CamWnd_setParent( *m_pCamWnd, window );
- g_floating_windows.push_back( GTK_WIDGET( window ) );
+ g_floating_windows.push_back( window );
}
{
- GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( XY ), m_window );
+ ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( XY ), m_window ));
global_accel_connect_window( window );
g_posXYWnd.connect( window );
{
- GtkFrame* frame = create_framed_widget( m_pXYWnd->GetWidget() );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) );
+ auto frame = create_framed_widget( m_pXYWnd->GetWidget() );
+ window.add(frame);
}
XY_Top_Shown_Construct( window );
- g_floating_windows.push_back( GTK_WIDGET( window ) );
+ g_floating_windows.push_back( window );
}
{
- GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( XZ ), m_window );
+ ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( XZ ), m_window ));
global_accel_connect_window( window );
g_posXZWnd.connect( window );
m_pXZWnd->SetViewType( XZ );
{
- GtkFrame* frame = create_framed_widget( m_pXZWnd->GetWidget() );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) );
+ auto frame = create_framed_widget( m_pXZWnd->GetWidget() );
+ window.add(frame);
}
XZ_Front_Shown_Construct( window );
- g_floating_windows.push_back( GTK_WIDGET( window ) );
+ g_floating_windows.push_back( window );
}
{
- GtkWindow* window = create_persistent_floating_window( ViewType_getTitle( YZ ), m_window );
+ ui::Window window = ui::Window(create_persistent_floating_window( ViewType_getTitle( YZ ), m_window ));
global_accel_connect_window( window );
g_posYZWnd.connect( window );
m_pYZWnd->SetViewType( YZ );
{
- GtkFrame* frame = create_framed_widget( m_pYZWnd->GetWidget() );
- gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( frame ) );
+ auto frame = create_framed_widget( m_pYZWnd->GetWidget() );
+ window.add(frame);
}
YZ_Side_Shown_Construct( window );
- g_floating_windows.push_back( GTK_WIDGET( window ) );
+ g_floating_windows.push_back( window );
}
{
- GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) );
- g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() );
+ auto frame = create_framed_widget( TextureBrowser_constructWindow( GroupDialog_getWindow() ) );
+ g_page_textures = GroupDialog_addPage( "Textures", frame, TextureBrowserExportTitleCaller() );
}
GroupDialog_show();
GlobalCamera_setCamWnd( *m_pCamWnd );
CamWnd_setParent( *m_pCamWnd, window );
- GtkWidget* camera = CamWnd_getWidget( *m_pCamWnd );
+ ui::Widget camera = CamWnd_getWidget( *m_pCamWnd );
m_pYZWnd = new XYWnd();
m_pYZWnd->SetViewType( YZ );
- GtkWidget* yz = m_pYZWnd->GetWidget();
+ ui::Widget yz = m_pYZWnd->GetWidget();
m_pXYWnd = new XYWnd();
m_pXYWnd->SetViewType( XY );
- GtkWidget* xy = m_pXYWnd->GetWidget();
+ ui::Widget xy = m_pXYWnd->GetWidget();
m_pXZWnd = new XYWnd();
m_pXZWnd->SetViewType( XZ );
- GtkWidget* xz = m_pXZWnd->GetWidget();
+ ui::Widget xz = m_pXZWnd->GetWidget();
- GtkHPaned* split = create_split_views( camera, yz, xy, xz );
- gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( split ), TRUE, TRUE, 0 );
+ auto split = create_split_views( camera, yz, xy, xz );
+ vbox.pack_start( split, TRUE, TRUE, 0 );
{
- GtkFrame* frame = create_framed_widget( TextureBrowser_constructWindow( window ) );
- g_page_textures = GroupDialog_addPage( "Textures", GTK_WIDGET( frame ), TextureBrowserExportTitleCaller() );
+ auto frame = create_framed_widget( TextureBrowser_constructWindow( window ) );
+ g_page_textures = GroupDialog_addPage( "Textures", frame, TextureBrowserExportTitleCaller() );
}
}
SetActiveXY( m_pXYWnd );
AddGridChangeCallback( SetGridStatusCaller( *this ) );
- AddGridChangeCallback( ReferenceCaller<MainFrame, XY_UpdateAllWindows>( *this ) );
+ AddGridChangeCallback( ReferenceCaller<MainFrame, void(), XY_UpdateAllWindows>( *this ) );
g_defaultToolMode = DragMode;
g_defaultToolMode();
g_layout_globals.m_position = m_position_tracker.getPosition();
- g_layout_globals.nState = gdk_window_get_state( GTK_WIDGET( m_window )->window );
+ g_layout_globals.nState = gdk_window_get_state( gtk_widget_get_window(m_window ) );
}
void MainFrame::Shutdown(){
}
void MainFrame::RedrawStatusText(){
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_command_status] ), m_command_status.c_str() );
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_position_status] ), m_position_status.c_str() );
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_brushcount_status] ), m_brushcount_status.c_str() );
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_texture_status] ), m_texture_status.c_str() );
- gtk_label_set_text( GTK_LABEL( m_pStatusLabel[c_grid_status] ), m_grid_status.c_str() );
+ ui::Label::from(m_pStatusLabel[c_command_status]).text(m_command_status.c_str());
+ ui::Label::from(m_pStatusLabel[c_position_status]).text(m_position_status.c_str());
+ ui::Label::from(m_pStatusLabel[c_brushcount_status]).text(m_brushcount_status.c_str());
+ ui::Label::from(m_pStatusLabel[c_texture_status]).text(m_texture_status.c_str());
+ ui::Label::from(m_pStatusLabel[c_grid_status]).text(m_grid_status.c_str());
}
void MainFrame::UpdateStatusText(){
}
float ( *GridStatus_getGridSize )() = GetGridSize;
+
int ( *GridStatus_getRotateIncrement )() = getRotateIncrement;
+
int ( *GridStatus_getFarClipDistance )() = getFarClipDistance;
+
bool ( *GridStatus_getTextureLockEnabled )();
void MainFrame::SetGridStatus(){
globalOutputStream() << "GL_VENDOR: " << reinterpret_cast<const char*>( glGetString( GL_VENDOR ) ) << "\n";
globalOutputStream() << "GL_RENDERER: " << reinterpret_cast<const char*>( glGetString( GL_RENDERER ) ) << "\n";
globalOutputStream() << "GL_VERSION: " << reinterpret_cast<const char*>( glGetString( GL_VERSION ) ) << "\n";
- globalOutputStream() << "GL_EXTENSIONS: " << reinterpret_cast<const char*>( glGetString( GL_EXTENSIONS ) ) << "\n";
+ const auto extensions = reinterpret_cast<const char*>( glGetString(GL_EXTENSIONS ) );
+ globalOutputStream() << "GL_EXTENSIONS: " << (extensions ? extensions : "") << "\n";
QGL_sharedContextCreated( GlobalOpenGL() );
GlobalShaderCache().realise();
Textures_Realise();
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
/* win32 is dodgy here, just use courier new then */
g_font = glfont_create( "arial 9" );
#else
- GtkSettings *settings = gtk_settings_get_default();
+ auto settings = gtk_settings_get_default();
gchar *fontname;
g_object_get( settings, "gtk-font-name", &fontname, NULL );
g_font = glfont_create( fontname );
void Layout_constructPreferences( PreferencesPage& page ){
{
- const char* layouts[] = { "window1.bmp", "window2.bmp", "window3.bmp", "window4.bmp" };
+ const char* layouts[] = { "window1.png", "window2.png", "window3.png", "window4.png" };
page.appendRadioIcons(
"Window Layout",
STRING_ARRAY_RANGE( layouts ),
- LatchedIntImportCaller( g_Layout_viewStyle ),
- IntExportCaller( g_Layout_viewStyle.m_latched )
+ make_property( g_Layout_viewStyle )
);
}
page.appendCheckBox(
"", "Detachable Menus",
- LatchedBoolImportCaller( g_Layout_enableDetachableMenus ),
- BoolExportCaller( g_Layout_enableDetachableMenus.m_latched )
+ make_property( g_Layout_enableDetachableMenus )
);
if ( !string_empty( g_pGameDescription->getKeyValue( "no_patch" ) ) ) {
page.appendCheckBox(
"", "Patch Toolbar",
- LatchedBoolImportCaller( g_Layout_enablePatchToolbar ),
- BoolExportCaller( g_Layout_enablePatchToolbar.m_latched )
+ make_property( g_Layout_enablePatchToolbar )
);
}
page.appendCheckBox(
"", "Plugin Toolbar",
- LatchedBoolImportCaller( g_Layout_enablePluginToolbar ),
- BoolExportCaller( g_Layout_enablePluginToolbar.m_latched )
+ make_property( g_Layout_enablePluginToolbar )
);
- LatchedBoolImportCaller( g_Layout_enableFilterToolbar ),
- BoolExportCaller( g_Layout_enableFilterToolbar.m_latched )
+ page.appendCheckBox(
+ "", "Filter Toolbar",
++ make_property( g_Layout_enableFilterToolbar )
+ );
}
void Layout_constructPage( PreferenceGroup& group ){
}
void Layout_registerPreferencesPage(){
- PreferencesDialog_addInterfacePage( FreeCaller1<PreferenceGroup&, Layout_constructPage>() );
+ PreferencesDialog_addInterfacePage( makeCallbackF(Layout_constructPage) );
}
#include "stringio.h"
void MainFrame_Construct(){
- GlobalCommands_insert( "OpenManual", FreeCaller<OpenHelpURL>(), Accelerator( GDK_F1 ) );
-
- GlobalCommands_insert( "Sleep", FreeCaller<thunk_OnSleep>(), Accelerator( 'P', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
- GlobalCommands_insert( "NewMap", FreeCaller<NewMap>() );
- GlobalCommands_insert( "OpenMap", FreeCaller<OpenMap>(), Accelerator( 'O', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "ImportMap", FreeCaller<ImportMap>() );
- GlobalCommands_insert( "SaveMap", FreeCaller<SaveMap>(), Accelerator( 'S', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "SaveMapAs", FreeCaller<SaveMapAs>() );
- GlobalCommands_insert( "SaveSelected", FreeCaller<ExportMap>() );
- GlobalCommands_insert( "SaveRegion", FreeCaller<SaveRegion>() );
- GlobalCommands_insert( "RefreshReferences", FreeCaller<RefreshReferences>() );
- GlobalCommands_insert( "ProjectSettings", FreeCaller<DoProjectSettings>() );
- GlobalCommands_insert( "CheckForUpdate", FreeCaller<OpenUpdateURL>() );
- GlobalCommands_insert( "Exit", FreeCaller<Exit>() );
-
- GlobalCommands_insert( "Undo", FreeCaller<Undo>(), Accelerator( 'Z', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "Redo", FreeCaller<Redo>(), Accelerator( 'Y', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "Copy", FreeCaller<Copy>(), Accelerator( 'C', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "Paste", FreeCaller<Paste>(), Accelerator( 'V', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "PasteToCamera", FreeCaller<PasteToCamera>(), Accelerator( 'V', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "CloneSelection", FreeCaller<Selection_Clone>(), Accelerator( GDK_space ) );
- GlobalCommands_insert( "CloneSelectionAndMakeUnique", FreeCaller<Selection_Clone_MakeUnique>(), Accelerator( GDK_space, (GdkModifierType)GDK_SHIFT_MASK ) );
-// GlobalCommands_insert( "DeleteSelection", FreeCaller<deleteSelection>(), Accelerator( GDK_BackSpace ) );
- GlobalCommands_insert( "DeleteSelection", FreeCaller<deleteSelection>(), Accelerator( 'Z' ) );
- GlobalCommands_insert( "ParentSelection", FreeCaller<Scene_parentSelected>() );
-// GlobalCommands_insert( "UnSelectSelection", FreeCaller<Selection_Deselect>(), Accelerator( GDK_Escape ) );
- GlobalCommands_insert( "UnSelectSelection", FreeCaller<Selection_Deselect>(), Accelerator( 'C' ) );
- GlobalCommands_insert( "InvertSelection", FreeCaller<Select_Invert>(), Accelerator( 'I' ) );
- GlobalCommands_insert( "SelectInside", FreeCaller<Select_Inside>() );
- GlobalCommands_insert( "SelectTouching", FreeCaller<Select_Touching>() );
- GlobalCommands_insert( "ExpandSelectionToEntities", FreeCaller<Scene_ExpandSelectionToEntities>(), Accelerator( 'E', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "Preferences", FreeCaller<PreferencesDialog_showDialog>(), Accelerator( 'P' ) );
-
- GlobalCommands_insert( "ToggleConsole", FreeCaller<Console_ToggleShow>(), Accelerator( 'O' ) );
- GlobalCommands_insert( "ToggleEntityInspector", FreeCaller<EntityInspector_ToggleShow>(), Accelerator( 'N' ) );
- GlobalCommands_insert( "EntityList", FreeCaller<EntityList_toggleShown>(), Accelerator( 'L' ) );
-
- GlobalCommands_insert( "ShowHidden", FreeCaller<Select_ShowAllHidden>(), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "HideSelected", FreeCaller<HideSelected>(), Accelerator( 'H' ) );
-
- GlobalToggles_insert( "DragVertices", FreeCaller<SelectVertexMode>(), ToggleItem::AddCallbackCaller( g_vertexMode_button ), Accelerator( 'V' ) );
- GlobalToggles_insert( "DragEdges", FreeCaller<SelectEdgeMode>(), ToggleItem::AddCallbackCaller( g_edgeMode_button ), Accelerator( 'E' ) );
- GlobalToggles_insert( "DragFaces", FreeCaller<SelectFaceMode>(), ToggleItem::AddCallbackCaller( g_faceMode_button ), Accelerator( 'F' ) );
-
- GlobalCommands_insert( "MirrorSelectionX", FreeCaller<Selection_Flipx>() );
- GlobalCommands_insert( "RotateSelectionX", FreeCaller<Selection_Rotatex>() );
- GlobalCommands_insert( "MirrorSelectionY", FreeCaller<Selection_Flipy>() );
- GlobalCommands_insert( "RotateSelectionY", FreeCaller<Selection_Rotatey>() );
- GlobalCommands_insert( "MirrorSelectionZ", FreeCaller<Selection_Flipz>() );
- GlobalCommands_insert( "RotateSelectionZ", FreeCaller<Selection_Rotatez>() );
-
- GlobalCommands_insert( "ArbitraryRotation", FreeCaller<DoRotateDlg>(), Accelerator( 'R', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "ArbitraryScale", FreeCaller<DoScaleDlg>(), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
-
- GlobalCommands_insert( "BuildMenuCustomize", FreeCaller<DoBuildMenu>() );
-
- GlobalCommands_insert( "FindBrush", FreeCaller<DoFind>() );
-
- GlobalCommands_insert( "MapInfo", FreeCaller<DoMapInfo>(), Accelerator( 'M' ) );
-
-
- GlobalToggles_insert( "ToggleClipper", FreeCaller<ClipperMode>(), ToggleItem::AddCallbackCaller( g_clipper_button ), Accelerator( 'X' ) );
-
- GlobalToggles_insert( "MouseTranslate", FreeCaller<TranslateMode>(), ToggleItem::AddCallbackCaller( g_translatemode_button ), Accelerator( 'W' ) );
- GlobalToggles_insert( "MouseRotate", FreeCaller<RotateMode>(), ToggleItem::AddCallbackCaller( g_rotatemode_button ), Accelerator( 'R' ) );
- GlobalToggles_insert( "MouseScale", FreeCaller<ScaleMode>(), ToggleItem::AddCallbackCaller( g_scalemode_button ) );
- GlobalToggles_insert( "MouseDrag", FreeCaller<DragMode>(), ToggleItem::AddCallbackCaller( g_dragmode_button ), Accelerator( 'Q' ) );
-
- GlobalCommands_insert( "ColorSchemeOriginal", FreeCaller<ColorScheme_Original>() );
- GlobalCommands_insert( "ColorSchemeQER", FreeCaller<ColorScheme_QER>() );
- GlobalCommands_insert( "ColorSchemeBlackAndGreen", FreeCaller<ColorScheme_Black>() );
- GlobalCommands_insert( "ColorSchemeYdnar", FreeCaller<ColorScheme_Ydnar>() );
+ GlobalCommands_insert( "OpenManual", makeCallbackF(OpenHelpURL), Accelerator( GDK_KEY_F1 ) );
+
+ GlobalCommands_insert( "Sleep", makeCallbackF(thunk_OnSleep), Accelerator( 'P', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "NewMap", makeCallbackF(NewMap) );
+ GlobalCommands_insert( "OpenMap", makeCallbackF(OpenMap), Accelerator( 'O', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "ImportMap", makeCallbackF(ImportMap) );
+ GlobalCommands_insert( "SaveMap", makeCallbackF(SaveMap), Accelerator( 'S', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "SaveMapAs", makeCallbackF(SaveMapAs) );
+ GlobalCommands_insert( "ExportSelected", makeCallbackF(ExportMap) );
+ GlobalCommands_insert( "SaveRegion", makeCallbackF(SaveRegion) );
+ GlobalCommands_insert( "RefreshReferences", makeCallbackF(VFS_Refresh) );
+ GlobalCommands_insert( "ProjectSettings", makeCallbackF(DoProjectSettings) );
+ GlobalCommands_insert( "Exit", makeCallbackF(Exit) );
+
+ GlobalCommands_insert( "Undo", makeCallbackF(Undo), Accelerator( 'Z', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "Redo", makeCallbackF(Redo), Accelerator( 'Y', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "Copy", makeCallbackF(Copy), Accelerator( 'C', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "Paste", makeCallbackF(Paste), Accelerator( 'V', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "PasteToCamera", makeCallbackF(PasteToCamera), Accelerator( 'V', (GdkModifierType)GDK_MOD1_MASK ) );
+ GlobalCommands_insert( "CloneSelection", makeCallbackF(Selection_Clone), Accelerator( GDK_KEY_space ) );
+ GlobalCommands_insert( "CloneSelectionAndMakeUnique", makeCallbackF(Selection_Clone_MakeUnique), Accelerator( GDK_KEY_space, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "DeleteSelection", makeCallbackF(deleteSelection), Accelerator( GDK_KEY_BackSpace ) );
+ GlobalCommands_insert( "ParentSelection", makeCallbackF(Scene_parentSelected) );
+ GlobalCommands_insert( "UnSelectSelection", makeCallbackF(Selection_Deselect), Accelerator( GDK_KEY_Escape ) );
+ GlobalCommands_insert( "InvertSelection", makeCallbackF(Select_Invert), Accelerator( 'I' ) );
+ GlobalCommands_insert( "SelectInside", makeCallbackF(Select_Inside) );
+ GlobalCommands_insert( "SelectTouching", makeCallbackF(Select_Touching) );
+ GlobalCommands_insert( "ExpandSelectionToEntities", makeCallbackF(Scene_ExpandSelectionToEntities), Accelerator( 'E', (GdkModifierType)( GDK_MOD1_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "Preferences", makeCallbackF(PreferencesDialog_showDialog), Accelerator( 'P' ) );
+
+ GlobalCommands_insert( "ToggleConsole", makeCallbackF(Console_ToggleShow), Accelerator( 'O' ) );
+ GlobalCommands_insert( "ToggleEntityInspector", makeCallbackF(EntityInspector_ToggleShow), Accelerator( 'N' ) );
+ GlobalCommands_insert( "EntityList", makeCallbackF(EntityList_toggleShown), Accelerator( 'L' ) );
+
+ GlobalCommands_insert( "ShowHidden", makeCallbackF(Select_ShowAllHidden), Accelerator( 'H', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "HideSelected", makeCallbackF(HideSelected), Accelerator( 'H' ) );
+
+ GlobalToggles_insert( "DragVertices", makeCallbackF(SelectVertexMode), ToggleItem::AddCallbackCaller( g_vertexMode_button ), Accelerator( 'V' ) );
+ GlobalToggles_insert( "DragEdges", makeCallbackF(SelectEdgeMode), ToggleItem::AddCallbackCaller( g_edgeMode_button ), Accelerator( 'E' ) );
+ GlobalToggles_insert( "DragFaces", makeCallbackF(SelectFaceMode), ToggleItem::AddCallbackCaller( g_faceMode_button ), Accelerator( 'F' ) );
+
+ GlobalCommands_insert( "MirrorSelectionX", makeCallbackF(Selection_Flipx) );
+ GlobalCommands_insert( "RotateSelectionX", makeCallbackF(Selection_Rotatex) );
+ GlobalCommands_insert( "MirrorSelectionY", makeCallbackF(Selection_Flipy) );
+ GlobalCommands_insert( "RotateSelectionY", makeCallbackF(Selection_Rotatey) );
+ GlobalCommands_insert( "MirrorSelectionZ", makeCallbackF(Selection_Flipz) );
+ GlobalCommands_insert( "RotateSelectionZ", makeCallbackF(Selection_Rotatez) );
+
+ GlobalCommands_insert( "ArbitraryRotation", makeCallbackF(DoRotateDlg) );
+ GlobalCommands_insert( "ArbitraryScale", makeCallbackF(DoScaleDlg) );
+
+ GlobalCommands_insert( "BuildMenuCustomize", makeCallbackF(DoBuildMenu) );
+
+ GlobalCommands_insert( "FindBrush", makeCallbackF(DoFind) );
+
+ GlobalCommands_insert( "MapInfo", makeCallbackF(DoMapInfo), Accelerator( 'M' ) );
+
+
+ GlobalToggles_insert( "ToggleClipper", makeCallbackF(ClipperMode), ToggleItem::AddCallbackCaller( g_clipper_button ), Accelerator( 'X' ) );
+
+ GlobalToggles_insert( "MouseTranslate", makeCallbackF(TranslateMode), ToggleItem::AddCallbackCaller( g_translatemode_button ), Accelerator( 'W' ) );
+ GlobalToggles_insert( "MouseRotate", makeCallbackF(RotateMode), ToggleItem::AddCallbackCaller( g_rotatemode_button ), Accelerator( 'R' ) );
+ GlobalToggles_insert( "MouseScale", makeCallbackF(ScaleMode), ToggleItem::AddCallbackCaller( g_scalemode_button ) );
+ GlobalToggles_insert( "MouseDrag", makeCallbackF(DragMode), ToggleItem::AddCallbackCaller( g_dragmode_button ), Accelerator( 'Q' ) );
+
+ GlobalCommands_insert( "ColorSchemeOriginal", makeCallbackF(ColorScheme_Original) );
+ GlobalCommands_insert( "ColorSchemeQER", makeCallbackF(ColorScheme_QER) );
+ GlobalCommands_insert( "ColorSchemeBlackAndGreen", makeCallbackF(ColorScheme_Black) );
+ GlobalCommands_insert( "ColorSchemeYdnar", makeCallbackF(ColorScheme_Ydnar) );
GlobalCommands_insert( "ChooseTextureBackgroundColor", makeCallback( g_ColoursMenu.m_textureback ) );
GlobalCommands_insert( "ChooseGridBackgroundColor", makeCallback( g_ColoursMenu.m_xyback ) );
GlobalCommands_insert( "ChooseGridMajorColor", makeCallback( g_ColoursMenu.m_gridmajor ) );
GlobalCommands_insert( "ChooseOrthoViewNameColor", makeCallback( g_ColoursMenu.m_viewname ) );
- GlobalCommands_insert( "CSGSubtract", FreeCaller<CSG_Subtract>(), Accelerator( 'U', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "CSGMerge", FreeCaller<CSG_Merge>(), Accelerator( 'U', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "CSGHollow", FreeCaller<CSG_MakeHollow>() );
+ GlobalCommands_insert( "CSGSubtract", makeCallbackF(CSG_Subtract), Accelerator( 'U', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "CSGMerge", makeCallbackF(CSG_Merge), Accelerator( 'U', (GdkModifierType) GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "CSGMakeHollow", makeCallbackF(CSG_MakeHollow) );
+ GlobalCommands_insert( "CSGMakeRoom", makeCallbackF(CSG_MakeRoom) );
Grid_registerCommands();
- GlobalCommands_insert( "SnapToGrid", FreeCaller<Selection_SnapToGrid>(), Accelerator( 'G', (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "SnapToGrid", makeCallbackF(Selection_SnapToGrid), Accelerator( 'G', (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "SelectAllOfType", FreeCaller<Select_AllOfType>(), Accelerator( 'A', (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "SelectAllOfType", makeCallbackF(Select_AllOfType), Accelerator( 'A', (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "TexRotateClock", FreeCaller<Texdef_RotateClockwise>(), Accelerator( GDK_Next, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "TexRotateCounter", FreeCaller<Texdef_RotateAntiClockwise>(), Accelerator( GDK_Prior, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "TexScaleUp", FreeCaller<Texdef_ScaleUp>(), Accelerator( GDK_Up, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "TexScaleDown", FreeCaller<Texdef_ScaleDown>(), Accelerator( GDK_Down, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "TexScaleLeft", FreeCaller<Texdef_ScaleLeft>(), Accelerator( GDK_Left, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "TexScaleRight", FreeCaller<Texdef_ScaleRight>(), Accelerator( GDK_Right, (GdkModifierType)GDK_CONTROL_MASK ) );
- GlobalCommands_insert( "TexShiftUp", FreeCaller<Texdef_ShiftUp>(), Accelerator( GDK_Up, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "TexShiftDown", FreeCaller<Texdef_ShiftDown>(), Accelerator( GDK_Down, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "TexShiftLeft", FreeCaller<Texdef_ShiftLeft>(), Accelerator( GDK_Left, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "TexShiftRight", FreeCaller<Texdef_ShiftRight>(), Accelerator( GDK_Right, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "TexRotateClock", makeCallbackF(Texdef_RotateClockwise), Accelerator( GDK_KEY_Next, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "TexRotateCounter", makeCallbackF(Texdef_RotateAntiClockwise), Accelerator( GDK_KEY_Prior, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "TexScaleUp", makeCallbackF(Texdef_ScaleUp), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "TexScaleDown", makeCallbackF(Texdef_ScaleDown), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "TexScaleLeft", makeCallbackF(Texdef_ScaleLeft), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "TexScaleRight", makeCallbackF(Texdef_ScaleRight), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_CONTROL_MASK ) );
+ GlobalCommands_insert( "TexShiftUp", makeCallbackF(Texdef_ShiftUp), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "TexShiftDown", makeCallbackF(Texdef_ShiftDown), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "TexShiftLeft", makeCallbackF(Texdef_ShiftLeft), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_SHIFT_MASK ) );
+ GlobalCommands_insert( "TexShiftRight", makeCallbackF(Texdef_ShiftRight), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_SHIFT_MASK ) );
- GlobalCommands_insert( "MoveSelectionDOWN", FreeCaller<Selection_MoveDown>(), Accelerator( GDK_KP_Subtract ) );
- GlobalCommands_insert( "MoveSelectionUP", FreeCaller<Selection_MoveUp>(), Accelerator( GDK_KP_Add ) );
+ GlobalCommands_insert( "MoveSelectionDOWN", makeCallbackF(Selection_MoveDown), Accelerator( GDK_KEY_KP_Subtract ) );
+ GlobalCommands_insert( "MoveSelectionUP", makeCallbackF(Selection_MoveUp), Accelerator( GDK_KEY_KP_Add ) );
- GlobalCommands_insert( "SelectNudgeLeft", FreeCaller<Selection_NudgeLeft>(), Accelerator( GDK_Left, (GdkModifierType)GDK_MOD1_MASK ) );
- GlobalCommands_insert( "SelectNudgeRight", FreeCaller<Selection_NudgeRight>(), Accelerator( GDK_Right, (GdkModifierType)GDK_MOD1_MASK ) );
- GlobalCommands_insert( "SelectNudgeUp", FreeCaller<Selection_NudgeUp>(), Accelerator( GDK_Up, (GdkModifierType)GDK_MOD1_MASK ) );
- GlobalCommands_insert( "SelectNudgeDown", FreeCaller<Selection_NudgeDown>(), Accelerator( GDK_Down, (GdkModifierType)GDK_MOD1_MASK ) );
+ GlobalCommands_insert( "SelectNudgeLeft", makeCallbackF(Selection_NudgeLeft), Accelerator( GDK_KEY_Left, (GdkModifierType)GDK_MOD1_MASK ) );
+ GlobalCommands_insert( "SelectNudgeRight", makeCallbackF(Selection_NudgeRight), Accelerator( GDK_KEY_Right, (GdkModifierType)GDK_MOD1_MASK ) );
+ GlobalCommands_insert( "SelectNudgeUp", makeCallbackF(Selection_NudgeUp), Accelerator( GDK_KEY_Up, (GdkModifierType)GDK_MOD1_MASK ) );
+ GlobalCommands_insert( "SelectNudgeDown", makeCallbackF(Selection_NudgeDown), Accelerator( GDK_KEY_Down, (GdkModifierType)GDK_MOD1_MASK ) );
Patch_registerCommands();
XYShow_registerCommands();
- typedef FreeCaller1<const Selectable&, ComponentMode_SelectionChanged> ComponentModeSelectionChangedCaller;
+ typedef FreeCaller<void(const Selectable&), ComponentMode_SelectionChanged> ComponentModeSelectionChangedCaller;
GlobalSelectionSystem().addSelectionChangeCallback( ComponentModeSelectionChangedCaller() );
- GlobalPreferenceSystem().registerPreference( "DetachableMenus", BoolImportStringCaller( g_Layout_enableDetachableMenus.m_latched ), BoolExportStringCaller( g_Layout_enableDetachableMenus.m_latched ) );
- GlobalPreferenceSystem().registerPreference( "PatchToolBar", BoolImportStringCaller( g_Layout_enablePatchToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePatchToolbar.m_latched ) );
- GlobalPreferenceSystem().registerPreference( "PluginToolBar", BoolImportStringCaller( g_Layout_enablePluginToolbar.m_latched ), BoolExportStringCaller( g_Layout_enablePluginToolbar.m_latched ) );
- GlobalPreferenceSystem().registerPreference( "FilterToolBar", BoolImportStringCaller( g_Layout_enableFilterToolbar.m_latched ), BoolExportStringCaller( g_Layout_enableFilterToolbar.m_latched ) );
- GlobalPreferenceSystem().registerPreference( "QE4StyleWindows", IntImportStringCaller( g_Layout_viewStyle.m_latched ), IntExportStringCaller( g_Layout_viewStyle.m_latched ) );
- GlobalPreferenceSystem().registerPreference( "XYHeight", IntImportStringCaller( g_layout_globals.nXYHeight ), IntExportStringCaller( g_layout_globals.nXYHeight ) );
- GlobalPreferenceSystem().registerPreference( "XYWidth", IntImportStringCaller( g_layout_globals.nXYWidth ), IntExportStringCaller( g_layout_globals.nXYWidth ) );
- GlobalPreferenceSystem().registerPreference( "CamWidth", IntImportStringCaller( g_layout_globals.nCamWidth ), IntExportStringCaller( g_layout_globals.nCamWidth ) );
- GlobalPreferenceSystem().registerPreference( "CamHeight", IntImportStringCaller( g_layout_globals.nCamHeight ), IntExportStringCaller( g_layout_globals.nCamHeight ) );
-
- GlobalPreferenceSystem().registerPreference( "State", IntImportStringCaller( g_layout_globals.nState ), IntExportStringCaller( g_layout_globals.nState ) );
- GlobalPreferenceSystem().registerPreference( "PositionX", IntImportStringCaller( g_layout_globals.m_position.x ), IntExportStringCaller( g_layout_globals.m_position.x ) );
- GlobalPreferenceSystem().registerPreference( "PositionY", IntImportStringCaller( g_layout_globals.m_position.y ), IntExportStringCaller( g_layout_globals.m_position.y ) );
- GlobalPreferenceSystem().registerPreference( "Width", IntImportStringCaller( g_layout_globals.m_position.w ), IntExportStringCaller( g_layout_globals.m_position.w ) );
- GlobalPreferenceSystem().registerPreference( "Height", IntImportStringCaller( g_layout_globals.m_position.h ), IntExportStringCaller( g_layout_globals.m_position.h ) );
-
- GlobalPreferenceSystem().registerPreference( "CamWnd", WindowPositionTrackerImportStringCaller( g_posCamWnd ), WindowPositionTrackerExportStringCaller( g_posCamWnd ) );
- GlobalPreferenceSystem().registerPreference( "XYWnd", WindowPositionTrackerImportStringCaller( g_posXYWnd ), WindowPositionTrackerExportStringCaller( g_posXYWnd ) );
- GlobalPreferenceSystem().registerPreference( "YZWnd", WindowPositionTrackerImportStringCaller( g_posYZWnd ), WindowPositionTrackerExportStringCaller( g_posYZWnd ) );
- GlobalPreferenceSystem().registerPreference( "XZWnd", WindowPositionTrackerImportStringCaller( g_posXZWnd ), WindowPositionTrackerExportStringCaller( g_posXZWnd ) );
+ GlobalPreferenceSystem().registerPreference( "DetachableMenus", make_property_string( g_Layout_enableDetachableMenus.m_latched ) );
+ GlobalPreferenceSystem().registerPreference( "PatchToolBar", make_property_string( g_Layout_enablePatchToolbar.m_latched ) );
+ GlobalPreferenceSystem().registerPreference( "PluginToolBar", make_property_string( g_Layout_enablePluginToolbar.m_latched ) );
++ GlobalPreferenceSystem().registerPreference( "FilterToolBar", make_property_string( g_Layout_enableFilterToolbar.m_latched ) );
+ GlobalPreferenceSystem().registerPreference( "QE4StyleWindows", make_property_string( g_Layout_viewStyle.m_latched ) );
+ GlobalPreferenceSystem().registerPreference( "XYHeight", make_property_string( g_layout_globals.nXYHeight ) );
+ GlobalPreferenceSystem().registerPreference( "XYWidth", make_property_string( g_layout_globals.nXYWidth ) );
+ GlobalPreferenceSystem().registerPreference( "CamWidth", make_property_string( g_layout_globals.nCamWidth ) );
+ GlobalPreferenceSystem().registerPreference( "CamHeight", make_property_string( g_layout_globals.nCamHeight ) );
+
+ GlobalPreferenceSystem().registerPreference( "State", make_property_string( g_layout_globals.nState ) );
+ GlobalPreferenceSystem().registerPreference( "PositionX", make_property_string( g_layout_globals.m_position.x ) );
+ GlobalPreferenceSystem().registerPreference( "PositionY", make_property_string( g_layout_globals.m_position.y ) );
+ GlobalPreferenceSystem().registerPreference( "Width", make_property_string( g_layout_globals.m_position.w ) );
+ GlobalPreferenceSystem().registerPreference( "Height", make_property_string( g_layout_globals.m_position.h ) );
+
+ GlobalPreferenceSystem().registerPreference( "CamWnd", make_property<WindowPositionTracker_String>(g_posCamWnd) );
+ GlobalPreferenceSystem().registerPreference( "XYWnd", make_property<WindowPositionTracker_String>(g_posXYWnd) );
+ GlobalPreferenceSystem().registerPreference( "YZWnd", make_property<WindowPositionTracker_String>(g_posYZWnd) );
+ GlobalPreferenceSystem().registerPreference( "XZWnd", make_property<WindowPositionTracker_String>(g_posXZWnd) );
{
const char* ENGINEPATH_ATTRIBUTE =
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
"enginepath_win32"
-#elif defined( __linux__ ) || defined ( __FreeBSD__ )
- "enginepath_linux"
-#elif defined( __APPLE__ )
+#elif GDEF_OS_MACOS
"enginepath_macos"
+#elif GDEF_OS_LINUX || GDEF_OS_BSD
+ "enginepath_linux"
#else
#error "unknown platform"
#endif
g_strEnginePath = path.c_str();
}
- GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) );
+ GlobalPreferenceSystem().registerPreference( "EnginePath", make_property_string( g_strEnginePath ) );
+
+ GlobalPreferenceSystem().registerPreference( "DisableEnginePath", make_property_string( g_disableEnginePath ) );
+ GlobalPreferenceSystem().registerPreference( "DisableHomePath", make_property_string( g_disableHomePath ) );
+
+ for ( int i = 0; i < g_pakPathCount; i++ ) {
+ std::string label = "PakPath" + std::to_string( i );
+ GlobalPreferenceSystem().registerPreference( label.c_str(), make_property_string( g_strPakPath[i] ) );
+ }
g_Layout_viewStyle.useLatched();
g_Layout_enableDetachableMenus.useLatched();
g_Layout_enablePatchToolbar.useLatched();
g_Layout_enablePluginToolbar.useLatched();
+ g_Layout_enableFilterToolbar.useLatched();
Layout_registerPreferencesPage();
Paths_registerPreferencesPage();
- g_brushCount.setCountChangedCallback( FreeCaller<QE_brushCountChanged>() );
- g_entityCount.setCountChangedCallback( FreeCaller<QE_entityCountChanged>() );
+ g_brushCount.setCountChangedCallback( makeCallbackF(QE_brushCountChanged) );
+ g_entityCount.setCountChangedCallback( makeCallbackF(QE_entityCountChanged) );
GlobalEntityCreator().setCounter( &g_entityCount );
GLWidget_sharedContextCreated = GlobalGL_sharedContextCreated;
GlobalEntityClassManager().detach( g_WorldspawnColourEntityClassObserver );
GlobalEntityCreator().setCounter( 0 );
- g_entityCount.setCountChangedCallback( Callback() );
- g_brushCount.setCountChangedCallback( Callback() );
+ g_entityCount.setCountChangedCallback( Callback<void()>() );
+ g_brushCount.setCountChangedCallback( Callback<void()>() );
}
void GLWindow_Construct(){
- GlobalPreferenceSystem().registerPreference( "MouseButtons", IntImportStringCaller( g_glwindow_globals.m_nMouseType ), IntExportStringCaller( g_glwindow_globals.m_nMouseType ) );
+ GlobalPreferenceSystem().registerPreference( "MouseButtons", make_property_string( g_glwindow_globals.m_nMouseType ) );
}
void GLWindow_Destroy(){
//
#include "preferences.h"
+#include "globaldefs.h"
+
+#include <gtk/gtk.h>
#include "environment.h"
#include "debugging/debugging.h"
-#include <gtk/gtkmain.h>
-#include <gtk/gtkvbox.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkframe.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtktogglebutton.h>
-#include <gtk/gtkspinbutton.h>
-#include <gtk/gtkscrolledwindow.h>
-#include <gtk/gtktreemodel.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtktreestore.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtknotebook.h>
-
#include "generic/callback.h"
#include "math/vector.h"
#include "string/string.h"
}
void Interface_constructPreferences( PreferencesPage& page ){
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
- page.appendCheckBox( "", "Default Text Editor", g_TextEditor_useWin32Editor );
+ page.appendCheckBox( "", "External Shader Editor", g_TextEditor_useWin32Editor );
#else
{
- GtkWidget* use_custom = page.appendCheckBox( "Text Editor", "Custom", g_TextEditor_useCustomEditor );
- GtkWidget* custom_editor = page.appendPathEntry( "Text Editor Command", g_TextEditor_editorCommand, true );
+ ui::CheckButton use_custom = page.appendCheckBox( "Text Editor", "Custom", g_TextEditor_useCustomEditor );
+ ui::Widget custom_editor = page.appendPathEntry( "Text Editor Command", g_TextEditor_editorCommand, true );
Widget_connectToggleDependency( custom_editor, use_custom );
}
#endif
Mouse_constructPreferences( page );
}
void Mouse_registerPreferencesPage(){
- PreferencesDialog_addInterfacePage( FreeCaller1<PreferenceGroup&, Mouse_constructPage>() );
+ PreferencesDialog_addInterfacePage( makeCallbackF(Mouse_constructPage) );
}
*/
#include <map>
+#include <uilib/uilib.h>
inline const char* xmlAttr_getName( xmlAttrPtr attr ){
return reinterpret_cast<const char*>( attr->name );
}
+struct LogConsole {
+ static void Export(const Callback<void(bool)> &returnz) {
+ returnz(g_Console_enableLogging);
+ }
-void LogConsole_importString( const char* string ){
- g_Console_enableLogging = string_equal( string, "true" );
- Sys_LogFile( g_Console_enableLogging );
-}
-typedef FreeCaller1<const char*, LogConsole_importString> LogConsoleImportStringCaller;
+ static void Import(bool value) {
+ g_Console_enableLogging = value;
+ Sys_LogFile(g_Console_enableLogging);
+ }
+};
void RegisterGlobalPreferences( PreferenceSystem& preferences ){
- preferences.registerPreference( "gamefile", CopiedStringImportStringCaller( g_GamesDialog.m_sGameFile ), CopiedStringExportStringCaller( g_GamesDialog.m_sGameFile ) );
- preferences.registerPreference( "gamePrompt", BoolImportStringCaller( g_GamesDialog.m_bGamePrompt ), BoolExportStringCaller( g_GamesDialog.m_bGamePrompt ) );
- preferences.registerPreference( "log console", LogConsoleImportStringCaller(), BoolExportStringCaller( g_Console_enableLogging ) );
+ preferences.registerPreference( "gamefile", make_property_string( g_GamesDialog.m_sGameFile ) );
+ preferences.registerPreference( "gamePrompt", make_property_string( g_GamesDialog.m_bGamePrompt ) );
+ preferences.registerPreference( "log console", make_property_string<LogConsole>() );
}
m_sGameFile = ( *iGame )->mGameFile;
}
-void CGameDialog::GameFileExport( const IntImportCallback& importCallback ) const {
+void CGameDialog::GameFileExport( const Callback<void(int)> & importCallback ) const {
// use m_sGameFile to set value
std::list<CGameDescription *>::const_iterator iGame;
int i = 0;
importCallback( m_nComboSelect );
}
-void CGameDialog_GameFileImport( CGameDialog& self, int value ){
- self.GameFileImport( value );
-}
+struct CGameDialog_GameFile {
+ static void Export(const CGameDialog &self, const Callback<void(int)> &returnz) {
+ self.GameFileExport(returnz);
+ }
-void CGameDialog_GameFileExport( CGameDialog& self, const IntImportCallback& importCallback ){
- self.GameFileExport( importCallback );
-}
+ static void Import(CGameDialog &self, int value) {
+ self.GameFileImport(value);
+ }
+};
void CGameDialog::CreateGlobalFrame( PreferencesPage& page ){
std::vector<const char*> games;
page.appendCombo(
"Select the game",
StringArrayRange( &( *games.begin() ), &( *games.end() ) ),
- ReferenceCaller1<CGameDialog, int, CGameDialog_GameFileImport>( *this ),
- ReferenceCaller1<CGameDialog, const IntImportCallback&, CGameDialog_GameFileExport>( *this )
+ make_property<CGameDialog_GameFile>(*this)
);
page.appendCheckBox( "Startup", "Show Global Preferences", m_bGamePrompt );
}
-GtkWindow* CGameDialog::BuildDialog(){
- GtkFrame* frame = create_dialog_frame( "Game settings", GTK_SHADOW_ETCHED_IN );
+ui::Window CGameDialog::BuildDialog(){
+ auto frame = create_dialog_frame( "Game settings", ui::Shadow::ETCHED_IN );
- GtkVBox* vbox2 = create_dialog_vbox( 0, 4 );
- gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) );
+ auto vbox2 = create_dialog_vbox( 0, 4 );
+ frame.add(vbox2);
{
- PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) );
+ PreferencesPage preferencesPage( *this, vbox2 );
Global_constructPreferences( preferencesPage );
CreateGlobalFrame( preferencesPage );
}
- return create_simple_modal_dialog_window( "Global Preferences", m_modal, GTK_WIDGET( frame ) );
-}
-
-class LoadGameFile
-{
-std::list<CGameDescription*>& mGames;
-const char* mPath;
-public:
-LoadGameFile( std::list<CGameDescription*>& games, const char* path ) : mGames( games ), mPath( path ){
-}
-void operator()( const char* name ) const {
- if ( !extension_equal( path_get_extension( name ), "game" ) ) {
- return;
- }
- StringOutputStream strPath( 256 );
- strPath << mPath << name;
- globalOutputStream() << strPath.c_str() << '\n';
-
- xmlDocPtr pDoc = xmlParseFile( strPath.c_str() );
- if ( pDoc ) {
- mGames.push_front( new CGameDescription( pDoc, name ) );
- xmlFreeDoc( pDoc );
- }
- else
- {
- globalErrorStream() << "XML parser failed on '" << strPath.c_str() << "'\n";
- }
+ return create_simple_modal_dialog_window( "Global Preferences", m_modal, frame );
}
-};
void CGameDialog::ScanForGames(){
StringOutputStream strGamesPath( 256 );
(if that's really needed)
*/
- Directory_forEach( path, LoadGameFile( mGames, path ) );
+ Directory_forEach(path, [&](const char *name) {
+ if (!extension_equal(path_get_extension(name), "game")) {
+ return;
+ }
+ StringOutputStream strPath(256);
+ strPath << path << name;
+ globalOutputStream() << strPath.c_str() << '\n';
+
+ xmlDocPtr pDoc = xmlParseFile(strPath.c_str());
+ if (pDoc) {
+ mGames.push_front(new CGameDescription(pDoc, name));
+ xmlFreeDoc(pDoc);
+ } else {
+ globalErrorStream() << "XML parser failed on '" << strPath.c_str() << "'\n";
+ }
+ });
}
CGameDescription* CGameDialog::GameDescriptionForComboItem(){
delete ( *iGame );
*iGame = 0;
}
- if ( GetWidget() != 0 ) {
+ if ( GetWidget() ) {
Destroy();
}
}
return identifier;
}
-void CGameDialog::AddPacksURL( StringOutputStream &URL ){
- // add the URLs for the list of game packs installed
- // FIXME: this is kinda hardcoded for now..
- std::list<CGameDescription *>::iterator iGame;
- for ( iGame = mGames.begin(); iGame != mGames.end(); ++iGame )
- {
- URL << "&Games_dlup%5B%5D=" << GameDescription_getIdentifier( *( *iGame ) );
- }
-}
CGameDialog g_GamesDialog;
// =============================================================================
// Widget callbacks for PrefsDlg
-static void OnButtonClean( GtkWidget *widget, gpointer data ){
+static void OnButtonClean( ui::Widget widget, gpointer data ){
// make sure this is what the user wants
- if ( gtk_MessageBox( GTK_WIDGET( g_Preferences.GetWidget() ), "This will close Radiant and clean the corresponding registry entries.\n"
+ if ( ui::alert( g_Preferences.GetWidget(), "This will close Radiant and clean the corresponding registry entries.\n"
"Next time you start Radiant it will be good as new. Do you wish to continue?",
- "Reset Registry", eMB_YESNO, eMB_ICONASTERISK ) == eIDYES ) {
+ "Reset Registry", ui::alert_type::YESNO, ui::alert_icon::Asterisk ) == ui::alert_response::YES ) {
PrefsDlg *dlg = (PrefsDlg*)data;
dlg->EndModal( eIDCANCEL );
========
*/
-#define PREFS_LOCAL_FILENAME "local.pref"
+const char *PREFS_LOCAL_FILENAME = "local.pref";
void PrefsDlg::Init(){
// m_global_rc_path has been set above
g_string_append( m_inipath, PREFS_LOCAL_FILENAME );
}
-void notebook_set_page( GtkWidget* notebook, GtkWidget* page ){
+void notebook_set_page( ui::Widget notebook, ui::Widget page ){
int pagenum = gtk_notebook_page_num( GTK_NOTEBOOK( notebook ), page );
if ( gtk_notebook_get_current_page( GTK_NOTEBOOK( notebook ) ) != pagenum ) {
gtk_notebook_set_current_page( GTK_NOTEBOOK( notebook ), pagenum );
}
}
-void PrefsDlg::showPrefPage( GtkWidget* prefpage ){
+void PrefsDlg::showPrefPage( ui::Widget prefpage ){
notebook_set_page( m_notebook, prefpage );
return;
}
-static void treeSelection( GtkTreeSelection* selection, gpointer data ){
+static void treeSelection( ui::TreeSelection selection, gpointer data ){
PrefsDlg *dlg = (PrefsDlg*)data;
GtkTreeModel* model;
GtkTreeIter selected;
if ( gtk_tree_selection_get_selected( selection, &model, &selected ) ) {
- GtkWidget* prefpage;
+ ui::Widget prefpage{ui::null};
gtk_tree_model_get( model, &selected, 1, (gpointer*)&prefpage, -1 );
dlg->showPrefPage( prefpage );
}
PreferenceGroupCallbacks_pushBack( g_settingsCallbacks, callback );
}
-void Widget_updateDependency( GtkWidget* self, GtkWidget* toggleButton ){
- gtk_widget_set_sensitive( self, gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( toggleButton ) ) && GTK_WIDGET_IS_SENSITIVE( toggleButton ) );
+void Widget_updateDependency( ui::Widget self, ui::Widget toggleButton ){
+ gtk_widget_set_sensitive( self, gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( toggleButton ) ) && gtk_widget_is_sensitive( toggleButton ) );
}
-void ToggleButton_toggled_Widget_updateDependency( GtkWidget *toggleButton, GtkWidget* self ){
+void ToggleButton_toggled_Widget_updateDependency( ui::Widget toggleButton, ui::Widget self ){
Widget_updateDependency( self, toggleButton );
}
-void ToggleButton_state_changed_Widget_updateDependency( GtkWidget* toggleButton, GtkStateType state, GtkWidget* self ){
+void ToggleButton_state_changed_Widget_updateDependency( ui::Widget toggleButton, GtkStateType state, ui::Widget self ){
if ( state == GTK_STATE_INSENSITIVE ) {
Widget_updateDependency( self, toggleButton );
}
}
-void Widget_connectToggleDependency( GtkWidget* self, GtkWidget* toggleButton ){
- g_signal_connect( G_OBJECT( toggleButton ), "state_changed", G_CALLBACK( ToggleButton_state_changed_Widget_updateDependency ), self );
- g_signal_connect( G_OBJECT( toggleButton ), "toggled", G_CALLBACK( ToggleButton_toggled_Widget_updateDependency ), self );
+void Widget_connectToggleDependency( ui::Widget self, ui::Widget toggleButton ){
+ toggleButton.connect( "state_changed", G_CALLBACK( ToggleButton_state_changed_Widget_updateDependency ), self );
+ toggleButton.connect( "toggled", G_CALLBACK( ToggleButton_toggled_Widget_updateDependency ), self );
Widget_updateDependency( self, toggleButton );
}
-inline GtkWidget* getVBox( GtkWidget* page ){
- return gtk_bin_get_child( GTK_BIN( page ) );
+inline ui::VBox getVBox( ui::Bin page ){
+ return ui::VBox::from(gtk_bin_get_child(page));
}
-GtkTreeIter PreferenceTree_appendPage( GtkTreeStore* store, GtkTreeIter* parent, const char* name, GtkWidget* page ){
+GtkTreeIter PreferenceTree_appendPage( ui::TreeStore store, GtkTreeIter* parent, const char* name, ui::Widget page ){
GtkTreeIter group;
gtk_tree_store_append( store, &group, parent );
gtk_tree_store_set( store, &group, 0, name, 1, page, -1 );
return group;
}
-GtkWidget* PreferencePages_addPage( GtkWidget* notebook, const char* name ){
- GtkWidget* preflabel = gtk_label_new( name );
- gtk_widget_show( preflabel );
+ui::Bin PreferencePages_addPage( ui::Widget notebook, const char* name ){
+ ui::Widget preflabel = ui::Label( name );
+ preflabel.show();
- GtkWidget* pageframe = gtk_frame_new( name );
+ auto pageframe = ui::Frame( name );
gtk_container_set_border_width( GTK_CONTAINER( pageframe ), 4 );
- gtk_widget_show( pageframe );
+ pageframe.show();
- GtkWidget* vbox = gtk_vbox_new( FALSE, 4 );
- gtk_widget_show( vbox );
+ ui::Widget vbox = ui::VBox( FALSE, 4 );
+ vbox.show();
gtk_container_set_border_width( GTK_CONTAINER( vbox ), 4 );
- gtk_container_add( GTK_CONTAINER( pageframe ), vbox );
+ pageframe.add(vbox);
// Add the page to the notebook
gtk_notebook_append_page( GTK_NOTEBOOK( notebook ), pageframe, preflabel );
class PreferenceTreeGroup : public PreferenceGroup
{
Dialog& m_dialog;
-GtkWidget* m_notebook;
-GtkTreeStore* m_store;
+ui::Widget m_notebook;
+ui::TreeStore m_store;
GtkTreeIter m_group;
public:
-PreferenceTreeGroup( Dialog& dialog, GtkWidget* notebook, GtkTreeStore* store, GtkTreeIter group ) :
+PreferenceTreeGroup( Dialog& dialog, ui::Widget notebook, ui::TreeStore store, GtkTreeIter group ) :
m_dialog( dialog ),
m_notebook( notebook ),
m_store( store ),
m_group( group ){
}
PreferencesPage createPage( const char* treeName, const char* frameName ){
- GtkWidget* page = PreferencePages_addPage( m_notebook, frameName );
+ auto page = PreferencePages_addPage( m_notebook, frameName );
PreferenceTree_appendPage( m_store, &m_group, treeName, page );
return PreferencesPage( m_dialog, getVBox( page ) );
}
};
-GtkWindow* PrefsDlg::BuildDialog(){
- PreferencesDialog_addInterfacePreferences( FreeCaller1<PreferencesPage&, Interface_constructPreferences>() );
+ui::Window PrefsDlg::BuildDialog(){
+ PreferencesDialog_addInterfacePreferences( makeCallbackF(Interface_constructPreferences) );
Mouse_registerPreferencesPage();
- GtkWindow* dialog = create_floating_window( "NetRadiant Preferences", m_parent );
+ ui::Window dialog = ui::Window(create_floating_window( "NetRadiant Preferences", m_parent ));
{
- GtkWidget* mainvbox = gtk_vbox_new( FALSE, 5 );
- gtk_container_add( GTK_CONTAINER( dialog ), mainvbox );
+ auto mainvbox = ui::VBox( FALSE, 5 );
+ dialog.add(mainvbox);
gtk_container_set_border_width( GTK_CONTAINER( mainvbox ), 5 );
- gtk_widget_show( mainvbox );
+ mainvbox.show();
{
- GtkWidget* hbox = gtk_hbox_new( FALSE, 5 );
- gtk_widget_show( hbox );
- gtk_box_pack_end( GTK_BOX( mainvbox ), hbox, FALSE, TRUE, 0 );
+ auto hbox = ui::HBox( FALSE, 5 );
+ hbox.show();
+ mainvbox.pack_end(hbox, FALSE, TRUE, 0);
{
- GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &m_modal );
- gtk_box_pack_end( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &m_modal );
+ hbox.pack_end(button, FALSE, FALSE, 0);
}
{
- GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &m_modal );
- gtk_box_pack_end( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &m_modal );
+ hbox.pack_end(button, FALSE, FALSE, 0);
}
{
- GtkButton* button = create_dialog_button( "Clean", G_CALLBACK( OnButtonClean ), this );
- gtk_box_pack_end( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
+ auto button = create_dialog_button( "Clean", G_CALLBACK( OnButtonClean ), this );
+ hbox.pack_end(button, FALSE, FALSE, 0);
}
}
{
- GtkWidget* hbox = gtk_hbox_new( FALSE, 5 );
- gtk_box_pack_start( GTK_BOX( mainvbox ), hbox, TRUE, TRUE, 0 );
- gtk_widget_show( hbox );
+ auto hbox = ui::HBox( FALSE, 5 );
+ mainvbox.pack_start( hbox, TRUE, TRUE, 0 );
+ hbox.show();
{
- GtkWidget* sc_win = gtk_scrolled_window_new( 0, 0 );
+ auto sc_win = ui::ScrolledWindow(ui::New);
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( sc_win ), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC );
- gtk_box_pack_start( GTK_BOX( hbox ), sc_win, FALSE, FALSE, 0 );
- gtk_widget_show( sc_win );
+ hbox.pack_start( sc_win, FALSE, FALSE, 0 );
+ sc_win.show();
gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( sc_win ), GTK_SHADOW_IN );
// prefs pages notebook
- m_notebook = gtk_notebook_new();
+ m_notebook = ui::Widget::from(gtk_notebook_new());
// hide the notebook tabs since its not supposed to look like a notebook
gtk_notebook_set_show_tabs( GTK_NOTEBOOK( m_notebook ), FALSE );
- gtk_box_pack_start( GTK_BOX( hbox ), m_notebook, TRUE, TRUE, 0 );
- gtk_widget_show( m_notebook );
+ hbox.pack_start( m_notebook, TRUE, TRUE, 0 );
+ m_notebook.show();
{
- GtkTreeStore* store = gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER );
+ auto store = ui::TreeStore::from(gtk_tree_store_new( 2, G_TYPE_STRING, G_TYPE_POINTER ));
- GtkWidget* view = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) );
- gtk_tree_view_set_headers_visible( GTK_TREE_VIEW( view ), FALSE );
+ auto view = ui::TreeView(ui::TreeModel::from(store._handle));
+ gtk_tree_view_set_headers_visible(view, FALSE );
{
- GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
- GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes( "Preferences", renderer, "text", 0, NULL );
- gtk_tree_view_append_column( GTK_TREE_VIEW( view ), column );
+ auto renderer = ui::CellRendererText(ui::New);
+ auto column = ui::TreeViewColumn( "Preferences", renderer, {{"text", 0}} );
+ gtk_tree_view_append_column(view, column );
}
{
- GtkTreeSelection* selection = gtk_tree_view_get_selection( GTK_TREE_VIEW( view ) );
- g_signal_connect( G_OBJECT( selection ), "changed", G_CALLBACK( treeSelection ), this );
+ auto selection = ui::TreeSelection::from(gtk_tree_view_get_selection(view));
+ selection.connect( "changed", G_CALLBACK( treeSelection ), this );
}
- gtk_widget_show( view );
+ view.show();
- gtk_container_add( GTK_CONTAINER( sc_win ), view );
+ sc_win.add(view);
{
/********************************************************************/
PreferencePages_addPage( m_notebook, "Front Page" );
{
- GtkWidget* global = PreferencePages_addPage( m_notebook, "Global Preferences" );
+ auto global = PreferencePages_addPage( m_notebook, "Global Preferences" );
{
PreferencesPage preferencesPage( *this, getVBox( global ) );
Global_constructPreferences( preferencesPage );
}
- GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Global", global );
+ auto group = PreferenceTree_appendPage( store, 0, "Global", global );
{
- GtkWidget* game = PreferencePages_addPage( m_notebook, "Game" );
+ auto game = PreferencePages_addPage( m_notebook, "Game" );
PreferencesPage preferencesPage( *this, getVBox( game ) );
g_GamesDialog.CreateGlobalFrame( preferencesPage );
}
{
- GtkWidget* interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" );
+ auto interfacePage = PreferencePages_addPage( m_notebook, "Interface Preferences" );
{
PreferencesPage preferencesPage( *this, getVBox( interfacePage ) );
PreferencesPageCallbacks_constructPage( g_interfacePreferences, preferencesPage );
}
- GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Interface", interfacePage );
+ auto group = PreferenceTree_appendPage( store, 0, "Interface", interfacePage );
PreferenceTreeGroup preferenceGroup( *this, m_notebook, store, group );
PreferenceGroupCallbacks_constructGroup( g_interfaceCallbacks, preferenceGroup );
}
{
- GtkWidget* display = PreferencePages_addPage( m_notebook, "Display Preferences" );
+ auto display = PreferencePages_addPage( m_notebook, "Display Preferences" );
{
PreferencesPage preferencesPage( *this, getVBox( display ) );
PreferencesPageCallbacks_constructPage( g_displayPreferences, preferencesPage );
}
- GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Display", display );
+ auto group = PreferenceTree_appendPage( store, 0, "Display", display );
PreferenceTreeGroup preferenceGroup( *this, m_notebook, store, group );
PreferenceGroupCallbacks_constructGroup( g_displayCallbacks, preferenceGroup );
}
{
- GtkWidget* settings = PreferencePages_addPage( m_notebook, "General Settings" );
+ auto settings = PreferencePages_addPage( m_notebook, "General Settings" );
{
PreferencesPage preferencesPage( *this, getVBox( settings ) );
PreferencesPageCallbacks_constructPage( g_settingsPreferences, preferencesPage );
}
- GtkTreeIter group = PreferenceTree_appendPage( store, 0, "Settings", settings );
+ auto group = PreferenceTree_appendPage( store, 0, "Settings", settings );
PreferenceTreeGroup preferenceGroup( *this, m_notebook, store, group );
PreferenceGroupCallbacks_constructGroup( g_settingsCallbacks, preferenceGroup );
}
}
- gtk_tree_view_expand_all( GTK_TREE_VIEW( view ) );
+ gtk_tree_view_expand_all(view );
g_object_unref( G_OBJECT( store ) );
}
}
}
- gtk_notebook_set_page( GTK_NOTEBOOK( m_notebook ), 0 );
+ gtk_notebook_set_current_page( GTK_NOTEBOOK( m_notebook ), 0 );
return dialog;
}
PrefsDlg g_Preferences; // global prefs instance
-void PreferencesDialog_constructWindow( GtkWindow* main_window ){
+void PreferencesDialog_constructWindow( ui::Window main_window ){
g_Preferences.m_parent = main_window;
g_Preferences.Create();
}
{
message << ( *i ) << '\n';
}
- gtk_MessageBox( GTK_WIDGET( MainFrame_getWindow() ), message.c_str() );
+ ui::alert( MainFrame_getWindow(), message.c_str() );
g_restart_required.clear();
}
}
}
+struct GameName {
+ static void Export(const Callback<void(const char *)> &returnz) {
+ returnz(gamename_get());
+ }
+ static void Import(const char *value) {
+ gamename_set(value);
+ }
+};
+struct GameMode {
+ static void Export(const Callback<void(const char *)> &returnz) {
+ returnz(gamemode_get());
+ }
-
-void GameName_importString( const char* value ){
- gamename_set( value );
-}
-typedef FreeCaller1<const char*, GameName_importString> GameNameImportStringCaller;
-void GameName_exportString( const StringImportCallback& importer ){
- importer( gamename_get() );
-}
-typedef FreeCaller1<const StringImportCallback&, GameName_exportString> GameNameExportStringCaller;
-
-void GameMode_importString( const char* value ){
- gamemode_set( value );
-}
-typedef FreeCaller1<const char*, GameMode_importString> GameModeImportStringCaller;
-void GameMode_exportString( const StringImportCallback& importer ){
- importer( gamemode_get() );
-}
-typedef FreeCaller1<const StringImportCallback&, GameMode_exportString> GameModeExportStringCaller;
-
+ static void Import(const char *value) {
+ gamemode_set(value);
+ }
+};
void RegisterPreferences( PreferenceSystem& preferences ){
-#ifdef WIN32
- preferences.registerPreference( "UseCustomShaderEditor", BoolImportStringCaller( g_TextEditor_useWin32Editor ), BoolExportStringCaller( g_TextEditor_useWin32Editor ) );
+#if GDEF_OS_WINDOWS
+ preferences.registerPreference( "UseCustomShaderEditor", make_property_string( g_TextEditor_useWin32Editor ) );
#else
- preferences.registerPreference( "UseCustomShaderEditor", BoolImportStringCaller( g_TextEditor_useCustomEditor ), BoolExportStringCaller( g_TextEditor_useCustomEditor ) );
- preferences.registerPreference( "CustomShaderEditorCommand", CopiedStringImportStringCaller( g_TextEditor_editorCommand ), CopiedStringExportStringCaller( g_TextEditor_editorCommand ) );
+ preferences.registerPreference( "UseCustomShaderEditor", make_property_string( g_TextEditor_useCustomEditor ) );
+ preferences.registerPreference( "CustomShaderEditorCommand", make_property_string( g_TextEditor_editorCommand ) );
#endif
- preferences.registerPreference( "GameName", GameNameImportStringCaller(), GameNameExportStringCaller() );
- preferences.registerPreference( "GameMode", GameModeImportStringCaller(), GameModeExportStringCaller() );
+ preferences.registerPreference( "GameName", make_property<GameName>() );
+ preferences.registerPreference( "GameMode", make_property<GameMode>() );
}
void Preferences_Init(){
/* get the model num */
value3 = ValueForKey( &entities[ j ], "model" );
if ( value3[ 0 ] == '\0' ) {
- Sys_Printf( "WARNING: Cloned entity %s referenced entity without model\n", value2 );
+ Sys_FPrintf( SYS_WRN, "WARNING: Cloned entity %s referenced entity without model\n", value2 );
continue;
}
- models = atoi( &value3[ 1 ] );
+ models = atoi( &value2[ 1 ] );
/* add the model key */
sprintf( modelValue, "*%d", models );
creates a full bsp + surfaces for the worldspawn entity
*/
-void ProcessWorldModel( void ){
+void ProcessWorldModel( const char *portalFilePath, const char *lineFilePath ){
int i, s;
entity_t *e;
tree_t *tree;
Sys_FPrintf( SYS_NOXML, "**********************\n" );
Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" );
Sys_FPrintf( SYS_NOXML, "**********************\n" );
- polyline = LeakFile( tree );
+ polyline = LeakFile( tree, lineFilePath );
leaknode = xmlNewNode( NULL, (xmlChar*)"message" );
xmlNodeSetContent( leaknode, (xmlChar*)"MAP LEAKED\n" );
xmlAddChild( leaknode, polyline );
/* save out information for visibility processing */
NumberClusters( tree );
if ( !leaked ) {
- WritePortalFile( tree );
+ WritePortalFile( tree, portalFilePath );
}
/* flood from entities */
process world + other models into the bsp
*/
-void ProcessModels( void ){
+void ProcessModels( const char *portalFilePath, const char *lineFilePath ){
qboolean oldVerbose;
entity_t *entity;
/* process the model */
Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
if ( mapEntityNum == 0 ) {
- ProcessWorldModel();
+ ProcessWorldModel(portalFilePath, lineFilePath);
}
else{
ProcessSubModel();
/* restore -v setting */
verbose = oldVerbose;
+ Sys_FPrintf( SYS_VRB, "%9i bspModels in total\n", numBSPModels );
+
/* write fogs */
EmitFogs();
this is probably broken unless teamed with a radiant version that preserves entity order
*/
-void OnlyEnts( void ){
- char out[ 1024 ];
-
+void OnlyEnts( const char *BSPFilePath ){
char save_cmdline[1024], save_version[1024], save_gridsize[1024];
const char *p;
/* note it */
Sys_Printf( "--- OnlyEnts ---\n" );
- sprintf( out, "%s.bsp", source );
- LoadBSPFile( out );
+ LoadBSPFile( BSPFilePath );
ParseEntities();
p = ValueForKey( &entities[0], "_q3map2_cmdline" );
numBSPEntities = numEntities;
UnparseEntities();
- WriteBSPFile( out );
+ WriteBSPFile( BSPFilePath );
}
int i;
char path[ 1024 ], tempSource[ 1024 ];
qboolean onlyents = qfalse;
+ char BSPFilePath [ 1024 ];
+ char lineFilePath [ 1024 ];
+ char portalFilePath [ 1024 ];
+ char surfaceFilePath [ 1024 ];
+ BSPFilePath[0] = 0;
+ lineFilePath[0] = 0;
+ portalFilePath[0] = 0;
+ surfaceFilePath[0] = 0;
/* note it */
Sys_Printf( "Max Area face surface generation enabled\n" );
maxAreaFaceSurface = qtrue;
}
+ else if ( !strcmp( argv[ i ], "-bspfile" ) )
+ {
+ strcpy( BSPFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as bsp file\n", BSPFilePath );
+ }
+ else if ( !strcmp( argv[ i ], "-linfile" ) )
+ {
+ strcpy( lineFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as line file\n", lineFilePath );
+ }
+ else if ( !strcmp( argv[ i ], "-prtfile" ) )
+ {
+ strcpy( portalFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as portal file\n", portalFilePath );
+ }
+ else if ( !strcmp( argv[ i ], "-srffile" ) )
+ {
+ strcpy( surfaceFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as surface file\n", surfaceFilePath );
+ }
else if ( !strcmp( argv[ i ], "-bsp" ) ) {
Sys_Printf( "-bsp argument unnecessary\n" );
}
/* ydnar: set default sample size */
SetDefaultSampleSize( sampleSize );
+ if (!BSPFilePath[0]) {
+ sprintf( BSPFilePath, "%s.bsp", source );
+ }
+ if (!lineFilePath[0]) {
+ sprintf( lineFilePath, "%s.lin", source );
+ }
+ if (!portalFilePath[0]) {
+ sprintf( portalFilePath, "%s.prt", source );
+ }
+ if (!surfaceFilePath[0]) {
+ sprintf( surfaceFilePath, "%s.srf", source );
+ }
+
/* delete portal, line and surface files */
- sprintf( path, "%s.prt", source );
- remove( path );
- sprintf( path, "%s.lin", source );
- remove( path );
- //% sprintf( path, "%s.srf", source ); /* ydnar */
- //% remove( path );
+ remove( portalFilePath );
+ remove( lineFilePath );
+ //% remove( surfaceFilePath ) /* ydnar */
/* expand mapname */
strcpy( name, ExpandArg( argv[ i ] ) );
/* if onlyents, just grab the entites and resave */
if ( onlyents ) {
- OnlyEnts();
+ OnlyEnts( BSPFilePath );
return 0;
}
SetCloneModelNumbers();
/* process world and submodels */
- ProcessModels();
+ ProcessModels( portalFilePath, lineFilePath );
/* set light styles from targetted light entities */
SetLightStyles();
ProcessAdvertisements();
/* finish and write bsp */
- EndBSPFile( qtrue );
+ EndBSPFile( qtrue, BSPFilePath, surfaceFilePath );
/* remove temp map source file if appropriate */
if ( strlen( tempSource ) > 0 ) {
/* get target */
e2 = FindTargetEntity( target );
if ( e2 == NULL ) {
- Sys_Printf( "WARNING: light at (%i %i %i) has missing target\n",
+ Sys_FPrintf( SYS_WRN, "WARNING: light at (%i %i %i) has missing target\n",
(int) light->origin[ 0 ], (int) light->origin[ 1 ], (int) light->origin[ 2 ] );
light->photons *= pointScale;
}
/* return to sender */
return 1;
}
- else{
+ else {
Error( "Light of undefined type!" );
}
does what it says...
*/
-void LightWorld( void ){
+void LightWorld( const char *BSPFilePath, qboolean fastAllocate ){
vec3_t color;
float f;
int b, bt;
/* find the optional minimum lighting values */
GetVectorForKey( &entities[ 0 ], "_color", color );
+ if ( VectorLength( color ) == 0.0f ) {
+ VectorSet( color, 1.0, 1.0, 1.0 );
+ }
+
if ( colorsRGB ) {
color[0] = Image_LinearFloatFromsRGBFloat( color[0] );
color[1] = Image_LinearFloatFromsRGBFloat( color[1] );
color[2] = Image_LinearFloatFromsRGBFloat( color[2] );
}
- if ( VectorLength( color ) == 0.0f ) {
- VectorSet( color, 1.0, 1.0, 1.0 );
- }
/* ambient */
f = FloatForKey( &entities[ 0 ], "_ambient" );
while ( bounce > 0 )
{
/* store off the bsp between bounces */
- StoreSurfaceLightmaps();
+ StoreSurfaceLightmaps( fastAllocate );
UnparseEntities();
- Sys_Printf( "Writing %s\n", source );
- WriteBSPFile( source );
+ Sys_Printf( "Writing %s\n", BSPFilePath );
+ WriteBSPFile( BSPFilePath );
/* note it */
Sys_Printf( "\n--- Radiosity (bounce %d of %d) ---\n", b, bt );
SetupEnvelopes( qfalse, fastbounce );
if ( numLights == 0 ) {
Sys_Printf( "No diffuse light to calculate, ending radiosity.\n" );
- break;
+ return;
}
/* add to lightgrid */
bounce--;
b++;
}
+ /* ydnar: store off lightmaps */
+ StoreSurfaceLightmaps( fastAllocate );
}
int LightMain( int argc, char **argv ){
int i;
float f;
- char mapSource[ 1024 ];
+ char BSPFilePath[ 1024 ];
+ char surfaceFilePath[ 1024 ];
+ BSPFilePath[0] = 0;
+ surfaceFilePath[0] = 0;
const char *value;
int lightmapMergeSize = 0;
qboolean lightSamplesInsist = qfalse;
-
+ qboolean fastAllocate = qfalse;
/* note it */
Sys_Printf( "--- Light ---\n" );
}
i++;
}
+
else if ( !strcmp( argv[ i ], "-deluxe" ) || !strcmp( argv[ i ], "-deluxemap" ) ) {
deluxemap = qtrue;
Sys_Printf( "Generating deluxemaps for average light direction\n" );
/* must be a power of 2 and greater than 2 */
if ( ( ( lmCustomSize - 1 ) & lmCustomSize ) || lmCustomSize < 2 ) {
- Sys_Printf( "WARNING: Lightmap size must be a power of 2, greater or equal to 2 pixels.\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: Lightmap size must be a power of 2, greater or equal to 2 pixels.\n" );
lmCustomSize = game->lightmapSize;
}
i++;
Sys_Printf( "Faster mode enabled\n" );
}
+ else if ( !strcmp( argv[ i ], "-fastallocate" ) ) {
+ fastAllocate = qtrue;
+ Sys_Printf( "Fast allocation mode enabled\n" );
+ }
+
else if ( !strcmp( argv[ i ], "-fastgrid" ) ) {
fastgrid = qtrue;
Sys_Printf( "Fast grid lighting enabled\n" );
i++;
Sys_Printf( "Lightmaps sample scale set to %d\n", sampleScale );
}
+ else if ( !strcmp( argv[ i ], "-debugsamplesize" ) ) {
+ debugSampleSize = 1;
+ Sys_Printf( "debugging Lightmaps SampleSize\n" );
+ }
else if ( !strcmp( argv[ i ], "-novertex" ) ) {
noVertexLighting = 1;
if ( ( atof( argv[ i + 1 ] ) != 0 ) && ( atof( argv[ i + 1 ] )) < 1 ) {
loMem = qtrue;
Sys_Printf( "Enabling low-memory (potentially slower) lighting mode\n" );
}
+ else if ( !strcmp( argv[ i ], "-lightsubdiv" ) ) {
+ defaultLightSubdivide = atoi( argv[ i + 1 ] );
+ if ( defaultLightSubdivide < 1 ) {
+ defaultLightSubdivide = 1;
+ }
+ i++;
+ Sys_Printf( "Default light subdivision set to %d\n", defaultLightSubdivide );
+ }
else if ( !strcmp( argv[ i ], "-lightanglehl" ) ) {
if ( ( atoi( argv[ i + 1 ] ) != 0 ) != lightAngleHL ) {
lightAngleHL = ( atoi( argv[ i + 1 ] ) != 0 );
lightmapFill = qtrue;
Sys_Printf( "Filling lightmap colors from surrounding pixels to improve JPEG compression\n" );
}
+ else if ( !strcmp( argv[ i ], "-bspfile" ) )
+ {
+ strcpy( BSPFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as bsp file\n", BSPFilePath );
+ }
+ else if ( !strcmp( argv[ i ], "-srffile" ) )
+ {
+ strcpy( surfaceFilePath, argv[i + 1] );
+ i++;
+ Sys_Printf( "Use %s as surface file\n", surfaceFilePath );
+ }
/* unhandled args */
else
{
- Sys_Printf( "WARNING: Unknown argument \"%s\"\n", argv[ i ] );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unknown argument \"%s\"\n", argv[ i ] );
}
}
Sys_Printf( "Restricted lightmap searching enabled - block size adjusted to %d\n", lightmapSearchBlockSize );
}
- /* clean up map name */
strcpy( source, ExpandArg( argv[ i ] ) );
StripExtension( source );
- DefaultExtension( source, ".bsp" );
- strcpy( mapSource, ExpandArg( argv[ i ] ) );
- StripExtension( mapSource );
- DefaultExtension( mapSource, ".map" );
+ DefaultExtension( source, ".map" );
+
+ if (!BSPFilePath[0]) {
+ strcpy( BSPFilePath, ExpandArg( argv[ i ] ) );
+ StripExtension( BSPFilePath );
+ DefaultExtension( BSPFilePath, ".bsp" );
+ }
+
+ if (!surfaceFilePath[0]) {
+ strcpy( surfaceFilePath, ExpandArg( argv[ i ] ) );
+ StripExtension( surfaceFilePath );
+ DefaultExtension( surfaceFilePath, ".srf" );
+ }
/* ydnar: set default sample size */
SetDefaultSampleSize( sampleSize );
/* ydnar: handle shaders */
- BeginMapShaderFile( source );
+ BeginMapShaderFile( BSPFilePath );
LoadShaderInfo();
/* note loading */
Sys_Printf( "Loading %s\n", source );
/* ydnar: load surface file */
- LoadSurfaceExtraFile( source );
+ LoadSurfaceExtraFile( surfaceFilePath );
/* load bsp file */
- LoadBSPFile( source );
+ LoadBSPFile( BSPFilePath );
/* parse bsp entities */
ParseEntities();
/* load map file */
value = ValueForKey( &entities[ 0 ], "_keepLights" );
if ( value[ 0 ] != '1' ) {
- LoadMapFile( mapSource, qtrue, qfalse );
+ LoadMapFile( source, qtrue, qfalse );
}
/* set the entity/model origins and init yDrawVerts */
SetupTraceNodes();
/* light the world */
- LightWorld();
-
- /* ydnar: store off lightmaps */
- StoreSurfaceLightmaps();
+ LightWorld( BSPFilePath, fastAllocate );
/* write out the bsp */
UnparseEntities();
- Sys_Printf( "Writing %s\n", source );
- WriteBSPFile( source );
+ Sys_Printf( "Writing %s\n", BSPFilePath );
+ WriteBSPFile( BSPFilePath );
/* ydnar: export lightmaps */
if ( exportLightmaps && !externalLightmaps ) {
/* dependencies */
#include "q3map2.h"
-
+#include <glib.h>
/* sanity check */
if ( bspLightBytes == NULL ) {
- Sys_Printf( "WARNING: No BSP lightmap data\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: No BSP lightmap data\n" );
return;
}
buffer = NULL;
len = vfsLoadFile( filename, (void*) &buffer, -1 );
if ( len < 0 ) {
- Sys_Printf( "WARNING: Unable to load image %s\n", filename );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unable to load image %s\n", filename );
continue;
}
/* sanity check it */
if ( pixels == NULL ) {
- Sys_Printf( "WARNING: Unable to load image %s\n", filename );
+ Sys_FPrintf( SYS_WRN, "WARNING: Unable to load image %s\n", filename );
continue;
}
if ( width != game->lightmapSize || height != game->lightmapSize ) {
- Sys_Printf( "WARNING: Image %s is not the right size (%d, %d) != (%d, %d)\n",
+ Sys_FPrintf( SYS_WRN, "WARNING: Image %s is not the right size (%d, %d) != (%d, %d)\n",
filename, width, height, game->lightmapSize, game->lightmapSize );
}
length = 0;
for ( x = 0; x < ( mesh->width - 1 ); x++ )
length += widthTable[ x ];
- lm->w = ceil( length / lm->sampleSize ) + 1;
+ lm->w = lm->sampleSize != 0 ? ceil( length / lm->sampleSize ) + 1 : 0;
if ( lm->w < ds->patchWidth ) {
lm->w = ds->patchWidth;
}
length = 0;
for ( y = 0; y < ( mesh->height - 1 ); y++ )
length += heightTable[ y ];
- lm->h = ceil( length / lm->sampleSize ) + 1;
+ lm->h = lm->sampleSize != 0 ? ceil( length / lm->sampleSize ) + 1 : 0;
if ( lm->h < ds->patchHeight ) {
lm->h = ds->patchHeight;
}
}
}
- if ( sampleSize != lm->sampleSize && lmLimitSize == 0 ) {
- Sys_FPrintf( SYS_VRB,"WARNING: surface at (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) too large for desired samplesize/lightmapsize/lightmapscale combination, increased samplesize from %d to %d\n",
- info->mins[0],
- info->mins[1],
- info->mins[2],
- info->maxs[0],
- info->maxs[1],
- info->maxs[2],
- lm->sampleSize,
- (int) sampleSize );
+ if ( sampleSize != lm->sampleSize && lmLimitSize == 0 ){
+ if ( debugSampleSize == 1 || lm->customWidth > 128 ){
+ Sys_FPrintf( SYS_VRB,"WARNING: surface at (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) too large for desired samplesize/lightmapsize/lightmapscale combination, increased samplesize from %d to %d\n",
+ info->mins[0],
+ info->mins[1],
+ info->mins[2],
+ info->maxs[0],
+ info->maxs[1],
+ info->maxs[2],
+ lm->sampleSize,
+ (int) sampleSize );
+ }
+ else if ( debugSampleSize == 0 ){
+ Sys_FPrintf( SYS_VRB,"WARNING: surface at (%6.0f %6.0f %6.0f) (%6.0f %6.0f %6.0f) too large for desired samplesize/lightmapsize/lightmapscale combination, increased samplesize from %d to %d\n",
+ info->mins[0],
+ info->mins[1],
+ info->mins[2],
+ info->maxs[0],
+ info->maxs[1],
+ info->maxs[2],
+ lm->sampleSize,
+ (int) sampleSize );
+ debugSampleSize--;
+ }
+ else{
+ debugSampleSize--;
+ }
}
/* set actual sample size */
/* check for bogus axis */
if ( faxis[ axisNum ] == 0.0f ) {
- Sys_Printf( "WARNING: ProjectSurfaceLightmap: Chose a 0 valued axis\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: ProjectSurfaceLightmap: Chose a 0 valued axis\n" );
lm->w = lm->h = 0;
return qfalse;
}
return -1;
}
-
/* then lightmap sample size */
if ( aInfo->sampleSize < bInfo->sampleSize ) {
return 1;
superSample = 1;
}
else if ( superSample > 8 ) {
- Sys_Printf( "WARNING: Insane supersampling amount (%d) detected.\n", superSample );
+ Sys_FPrintf( SYS_WRN, "WARNING: Insane supersampling amount (%d) detected.\n", superSample );
superSample = 8;
}
FinishRawLightmap( lm );
}
+ if ( debugSampleSize < -1 ){
+ Sys_FPrintf( SYS_VRB, "+%d similar occurrences;\t-debugSampleSize to show ones\n", -debugSampleSize - 1 );
+ }
+
/* allocate vertex luxel storage */
for ( k = 0; k < MAX_LIGHTMAPS; k++ )
{
*/
#define LIGHTMAP_RESERVE_COUNT 1
-static void FindOutLightmaps( rawLightmap_t *lm ){
+static void FindOutLightmaps( rawLightmap_t *lm, qboolean fastAllocate ){
int i, j, k, lightmapNum, xMax, yMax, x = -1, y = -1, sx, sy, ox, oy, offset;
outLightmap_t *olm;
surfaceInfo_t *info;
vec3_t color, direction;
byte *pixel;
qboolean ok;
+ int xIncrement, yIncrement;
/* set default lightmap number (-3 = LIGHTMAP_BY_VERTEX) */
continue;
}
+ /* if fast allocation, skip lightmap files that are more than 90% complete */
+ if ( fastAllocate == qtrue ) {
+ if (olm->freeLuxels < (olm->customWidth * olm->customHeight) / 10) {
+ continue;
+ }
+ }
+
/* don't store non-custom raw lightmaps on custom bsp lightmaps */
if ( olm->customWidth != lm->customWidth ||
olm->customHeight != lm->customHeight ) {
yMax = ( olm->customHeight - lm->h ) + 1;
}
+ /* if fast allocation, do not test allocation on every pixels, especially for large lightmaps */
+ if ( fastAllocate == qtrue ) {
+ xIncrement = MAX(1, lm->w / 15);
+ yIncrement = MAX(1, lm->h / 15);
+ }
+ else {
+ xIncrement = 1;
+ yIncrement = 1;
+ }
+
/* walk the origin around the lightmap */
- for ( y = 0; y < yMax; y++ )
+ for ( y = 0; y < yMax; y += yIncrement )
{
- for ( x = 0; x < xMax; x++ )
+ for ( x = 0; x < xMax; x += xIncrement )
{
/* find a fine tract of lauhnd */
ok = TestOutLightmapStamp( lm, lightmapNum, olm, x, y );
return 0;
}
+
+
void FillOutLightmap( outLightmap_t *olm ){
int x, y;
int ofs;
}
}
+
+
/*
StoreSurfaceLightmaps()
stores the surface lightmaps into the bsp as byte rgb triplets
*/
-void StoreSurfaceLightmaps( void ){
+void StoreSurfaceLightmaps( qboolean fastAllocate ){
int i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples;
int style, size, lightmapNum, lightmapNum2;
float *normal, *luxel, *bspLuxel, *bspLuxel2, *radLuxel, samples, occludedSamples;
char dirname[ 1024 ], filename[ 1024 ];
shaderInfo_t *csi;
char lightmapName[ 128 ];
- const char *rgbGenValues[ 256 ];
- const char *alphaGenValues[ 256 ];
+ const char *rgbGenValues[ 256 ];
+ const char *alphaGenValues[ 256 ];
/* note it */
----------------------------------------------------------------- */
/* note it */
- Sys_Printf( "Subsampling..." );
+ Sys_FPrintf( SYS_VRB, "Subsampling..." );
/* walk the list of raw lightmaps */
numUsed = 0;
if ( noCollapse == qfalse && deluxemap == qfalse ) {
/* note it */
- Sys_Printf( "collapsing..." );
+ Sys_FPrintf( SYS_VRB, "collapsing..." );
/* set all twin refs to null */
for ( i = 0; i < numRawLightmaps; i++ )
----------------------------------------------------------------- */
/* note it */
- Sys_Printf( "sorting..." );
+ Sys_FPrintf( SYS_VRB, "sorting..." );
/* allocate a new sorted list */
if ( sortLightmaps == NULL ) {
----------------------------------------------------------------- */
/* note it */
- Sys_Printf( "allocating..." );
+ Sys_FPrintf( SYS_VRB, "allocating..." );
/* kill all existing output lightmaps */
if ( outLightmaps != NULL ) {
for ( i = 0; i < numRawLightmaps; i++ )
{
lm = &rawLightmaps[ sortLightmaps[ i ] ];
- FindOutLightmaps( lm );
+ FindOutLightmaps( lm, fastAllocate );
}
/* set output numbers in twinned lightmaps */
----------------------------------------------------------------- */
/* note it */
- Sys_Printf( "storing..." );
+ Sys_FPrintf( SYS_VRB, "storing..." );
/* count the bsp lightmaps and allocate space */
if ( bspLightBytes != NULL ) {
}
if ( numExtLightmaps > 0 ) {
- Sys_Printf( "\n" );
+ Sys_FPrintf( SYS_VRB, "\n" );
}
/* delete unused external lightmaps */
----------------------------------------------------------------- */
/* note it */
- Sys_Printf( "projecting..." );
+ Sys_FPrintf( SYS_VRB, "projecting..." );
/* walk the list of surfaces */
for ( i = 0; i < numBSPDrawSurfaces; i++ )
}
/* finish */
- Sys_Printf( "done.\n" );
+ Sys_FPrintf( SYS_VRB, "done.\n" );
/* calc num stored */
numStored = numBSPLightBytes / 3;
-/* -------------------------------------------------------------------------------;
+/* -------------------------------------------------------------------------------
Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
/* dependencies */
#include "q3map2.h"
-
-
-
-/*
- Random()
- returns a pseudorandom number between 0 and 1
- */
-
-vec_t Random( void ){
- return (vec_t) rand() / RAND_MAX;
-}
-
-
-char *Q_strncpyz( char *dst, const char *src, size_t len ) {
- if ( len == 0 ) {
- abort();
- }
-
- strncpy( dst, src, len );
- dst[ len - 1 ] = '\0';
- return dst;
-}
-
-
-char *Q_strcat( char *dst, size_t dlen, const char *src ) {
- size_t n = strlen( dst );
-
- if ( n > dlen ) {
- abort(); /* buffer overflow */
- }
-
- return Q_strncpyz( dst + n, src, dlen - n );
-}
-
-
-char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen ) {
- size_t n = strlen( dst );
-
- if ( n > dlen ) {
- abort(); /* buffer overflow */
- }
-
- return Q_strncpyz( dst + n, src, MIN( slen, dlen - n ) );
-}
-
-
-/*
- ExitQ3Map()
- cleanup routine
- */
-
-static void ExitQ3Map( void ){
- BSPFilesCleanup();
- if ( mapDrawSurfs != NULL ) {
- free( mapDrawSurfs );
- }
-}
-
-
-
-/* minimap stuff */
-
-typedef struct minimap_s
-{
- bspModel_t *model;
- int width;
- int height;
- int samples;
- float *sample_offsets;
- float sharpen_boxmult;
- float sharpen_centermult;
- float boost, brightness, contrast;
- float *data1f;
- float *sharpendata1f;
- vec3_t mins, size;
-}
-minimap_t;
-static minimap_t minimap;
-
-qboolean BrushIntersectionWithLine( bspBrush_t *brush, vec3_t start, vec3_t dir, float *t_in, float *t_out ){
- int i;
- qboolean in = qfalse, out = qfalse;
- bspBrushSide_t *sides = &bspBrushSides[brush->firstSide];
-
- for ( i = 0; i < brush->numSides; ++i )
- {
- bspPlane_t *p = &bspPlanes[sides[i].planeNum];
- float sn = DotProduct( start, p->normal );
- float dn = DotProduct( dir, p->normal );
- if ( dn == 0 ) {
- if ( sn > p->dist ) {
- return qfalse; // outside!
- }
- }
- else
- {
- float t = ( p->dist - sn ) / dn;
- if ( dn < 0 ) {
- if ( !in || t > *t_in ) {
- *t_in = t;
- in = qtrue;
- // as t_in can only increase, and t_out can only decrease, early out
- if ( out && *t_in >= *t_out ) {
- return qfalse;
- }
- }
- }
- else
- {
- if ( !out || t < *t_out ) {
- *t_out = t;
- out = qtrue;
- // as t_in can only increase, and t_out can only decrease, early out
- if ( in && *t_in >= *t_out ) {
- return qfalse;
- }
- }
- }
- }
- }
- return in && out;
-}
-
-static float MiniMapSample( float x, float y ){
- vec3_t org, dir;
- int i, bi;
- float t0, t1;
- float samp;
- bspBrush_t *b;
- bspBrushSide_t *s;
- int cnt;
-
- org[0] = x;
- org[1] = y;
- org[2] = 0;
- dir[0] = 0;
- dir[1] = 0;
- dir[2] = 1;
-
- cnt = 0;
- samp = 0;
- for ( i = 0; i < minimap.model->numBSPBrushes; ++i )
- {
- bi = minimap.model->firstBSPBrush + i;
- if ( opaqueBrushes[bi >> 3] & ( 1 << ( bi & 7 ) ) ) {
- b = &bspBrushes[bi];
-
- // sort out mins/maxs of the brush
- s = &bspBrushSides[b->firstSide];
- if ( x < -bspPlanes[s[0].planeNum].dist ) {
- continue;
- }
- if ( x > +bspPlanes[s[1].planeNum].dist ) {
- continue;
- }
- if ( y < -bspPlanes[s[2].planeNum].dist ) {
- continue;
- }
- if ( y > +bspPlanes[s[3].planeNum].dist ) {
- continue;
- }
-
- if ( BrushIntersectionWithLine( b, org, dir, &t0, &t1 ) ) {
- samp += t1 - t0;
- ++cnt;
- }
- }
- }
-
- return samp;
-}
-
-void RandomVector2f( float v[2] ){
- do
- {
- v[0] = 2 * Random() - 1;
- v[1] = 2 * Random() - 1;
- }
- while ( v[0] * v[0] + v[1] * v[1] > 1 );
-}
-
-static void MiniMapRandomlySupersampled( int y ){
- int x, i;
- float *p = &minimap.data1f[y * minimap.width];
- float ymin = minimap.mins[1] + minimap.size[1] * ( y / (float) minimap.height );
- float dx = minimap.size[0] / (float) minimap.width;
- float dy = minimap.size[1] / (float) minimap.height;
- float uv[2];
- float thisval;
-
- for ( x = 0; x < minimap.width; ++x )
- {
- float xmin = minimap.mins[0] + minimap.size[0] * ( x / (float) minimap.width );
- float val = 0;
-
- for ( i = 0; i < minimap.samples; ++i )
- {
- RandomVector2f( uv );
- thisval = MiniMapSample(
- xmin + ( uv[0] + 0.5 ) * dx, /* exaggerated random pattern for better results */
- ymin + ( uv[1] + 0.5 ) * dy /* exaggerated random pattern for better results */
- );
- val += thisval;
- }
- val /= minimap.samples * minimap.size[2];
- *p++ = val;
- }
-}
-
-static void MiniMapSupersampled( int y ){
- int x, i;
- float *p = &minimap.data1f[y * minimap.width];
- float ymin = minimap.mins[1] + minimap.size[1] * ( y / (float) minimap.height );
- float dx = minimap.size[0] / (float) minimap.width;
- float dy = minimap.size[1] / (float) minimap.height;
-
- for ( x = 0; x < minimap.width; ++x )
- {
- float xmin = minimap.mins[0] + minimap.size[0] * ( x / (float) minimap.width );
- float val = 0;
-
- for ( i = 0; i < minimap.samples; ++i )
- {
- float thisval = MiniMapSample(
- xmin + minimap.sample_offsets[2 * i + 0] * dx,
- ymin + minimap.sample_offsets[2 * i + 1] * dy
- );
- val += thisval;
- }
- val /= minimap.samples * minimap.size[2];
- *p++ = val;
- }
-}
-
-static void MiniMapNoSupersampling( int y ){
- int x;
- float *p = &minimap.data1f[y * minimap.width];
- float ymin = minimap.mins[1] + minimap.size[1] * ( ( y + 0.5 ) / (float) minimap.height );
-
- for ( x = 0; x < minimap.width; ++x )
- {
- float xmin = minimap.mins[0] + minimap.size[0] * ( ( x + 0.5 ) / (float) minimap.width );
- *p++ = MiniMapSample( xmin, ymin ) / minimap.size[2];
- }
-}
-
-static void MiniMapSharpen( int y ){
- int x;
- qboolean up = ( y > 0 );
- qboolean down = ( y < minimap.height - 1 );
- float *p = &minimap.data1f[y * minimap.width];
- float *q = &minimap.sharpendata1f[y * minimap.width];
-
- for ( x = 0; x < minimap.width; ++x )
- {
- qboolean left = ( x > 0 );
- qboolean right = ( x < minimap.width - 1 );
- float val = p[0] * minimap.sharpen_centermult;
-
- if ( left && up ) {
- val += p[-1 - minimap.width] * minimap.sharpen_boxmult;
- }
- if ( left && down ) {
- val += p[-1 + minimap.width] * minimap.sharpen_boxmult;
- }
- if ( right && up ) {
- val += p[+1 - minimap.width] * minimap.sharpen_boxmult;
- }
- if ( right && down ) {
- val += p[+1 + minimap.width] * minimap.sharpen_boxmult;
- }
-
- if ( left ) {
- val += p[-1] * minimap.sharpen_boxmult;
- }
- if ( right ) {
- val += p[+1] * minimap.sharpen_boxmult;
- }
- if ( up ) {
- val += p[-minimap.width] * minimap.sharpen_boxmult;
- }
- if ( down ) {
- val += p[+minimap.width] * minimap.sharpen_boxmult;
- }
-
- ++p;
- *q++ = val;
- }
-}
-
-static void MiniMapContrastBoost( int y ){
- int x;
- float *q = &minimap.data1f[y * minimap.width];
- for ( x = 0; x < minimap.width; ++x )
- {
- *q = *q * minimap.boost / ( ( minimap.boost - 1 ) * *q + 1 );
- ++q;
- }
-}
-
-static void MiniMapBrightnessContrast( int y ){
- int x;
- float *q = &minimap.data1f[y * minimap.width];
- for ( x = 0; x < minimap.width; ++x )
- {
- *q = *q * minimap.contrast + minimap.brightness;
- ++q;
- }
-}
-
-void MiniMapMakeMinsMaxs( vec3_t mins_in, vec3_t maxs_in, float border, qboolean keepaspect ){
- vec3_t mins, maxs, extend;
- VectorCopy( mins_in, mins );
- VectorCopy( maxs_in, maxs );
-
- // line compatible to nexuiz mapinfo
- Sys_Printf( "size %f %f %f %f %f %f\n", mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2] );
-
- if ( keepaspect ) {
- VectorSubtract( maxs, mins, extend );
- if ( extend[1] > extend[0] ) {
- mins[0] -= ( extend[1] - extend[0] ) * 0.5;
- maxs[0] += ( extend[1] - extend[0] ) * 0.5;
- }
- else
- {
- mins[1] -= ( extend[0] - extend[1] ) * 0.5;
- maxs[1] += ( extend[0] - extend[1] ) * 0.5;
- }
- }
-
- /* border: amount of black area around the image */
- /* input: border, 1-2*border, border but we need border/(1-2*border) */
-
- VectorSubtract( maxs, mins, extend );
- VectorScale( extend, border / ( 1 - 2 * border ), extend );
-
- VectorSubtract( mins, extend, mins );
- VectorAdd( maxs, extend, maxs );
-
- VectorCopy( mins, minimap.mins );
- VectorSubtract( maxs, mins, minimap.size );
-
- // line compatible to nexuiz mapinfo
- Sys_Printf( "size_texcoords %f %f %f %f %f %f\n", mins[0], mins[1], mins[2], maxs[0], maxs[1], maxs[2] );
-}
-
-/*
- MiniMapSetupBrushes()
- determines solid non-sky brushes in the world
- */
-
-void MiniMapSetupBrushes( void ){
- SetupBrushesFlags( C_SOLID | C_SKY, C_SOLID, 0, 0 );
- // at least one must be solid
- // none may be sky
- // not all may be nodraw
-}
-
-qboolean MiniMapEvaluateSampleOffsets( int *bestj, int *bestk, float *bestval ){
- float val, dx, dy;
- int j, k;
-
- *bestj = *bestk = -1;
- *bestval = 3; /* max possible val is 2 */
-
- for ( j = 0; j < minimap.samples; ++j )
- for ( k = j + 1; k < minimap.samples; ++k )
- {
- dx = minimap.sample_offsets[2 * j + 0] - minimap.sample_offsets[2 * k + 0];
- dy = minimap.sample_offsets[2 * j + 1] - minimap.sample_offsets[2 * k + 1];
- if ( dx > +0.5 ) {
- dx -= 1;
- }
- if ( dx < -0.5 ) {
- dx += 1;
- }
- if ( dy > +0.5 ) {
- dy -= 1;
- }
- if ( dy < -0.5 ) {
- dy += 1;
- }
- val = dx * dx + dy * dy;
- if ( val < *bestval ) {
- *bestj = j;
- *bestk = k;
- *bestval = val;
- }
- }
-
- return *bestval < 3;
-}
-
-void MiniMapMakeSampleOffsets(){
- int i, j, k, jj, kk;
- float val, valj, valk, sx, sy, rx, ry;
-
- Sys_Printf( "Generating good sample offsets (this may take a while)...\n" );
-
- /* start with entirely random samples */
- for ( i = 0; i < minimap.samples; ++i )
- {
- minimap.sample_offsets[2 * i + 0] = Random();
- minimap.sample_offsets[2 * i + 1] = Random();
- }
-
- for ( i = 0; i < 1000; ++i )
- {
- if ( MiniMapEvaluateSampleOffsets( &j, &k, &val ) ) {
- sx = minimap.sample_offsets[2 * j + 0];
- sy = minimap.sample_offsets[2 * j + 1];
- minimap.sample_offsets[2 * j + 0] = rx = Random();
- minimap.sample_offsets[2 * j + 1] = ry = Random();
- if ( !MiniMapEvaluateSampleOffsets( &jj, &kk, &valj ) ) {
- valj = -1;
- }
- minimap.sample_offsets[2 * j + 0] = sx;
- minimap.sample_offsets[2 * j + 1] = sy;
-
- sx = minimap.sample_offsets[2 * k + 0];
- sy = minimap.sample_offsets[2 * k + 1];
- minimap.sample_offsets[2 * k + 0] = rx;
- minimap.sample_offsets[2 * k + 1] = ry;
- if ( !MiniMapEvaluateSampleOffsets( &jj, &kk, &valk ) ) {
- valk = -1;
- }
- minimap.sample_offsets[2 * k + 0] = sx;
- minimap.sample_offsets[2 * k + 1] = sy;
-
- if ( valj > valk ) {
- if ( valj > val ) {
- /* valj is the greatest */
- minimap.sample_offsets[2 * j + 0] = rx;
- minimap.sample_offsets[2 * j + 1] = ry;
- i = -1;
- }
- else
- {
- /* valj is the greater and it is useless - forget it */
- }
- }
- else
- {
- if ( valk > val ) {
- /* valk is the greatest */
- minimap.sample_offsets[2 * k + 0] = rx;
- minimap.sample_offsets[2 * k + 1] = ry;
- i = -1;
- }
- else
- {
- /* valk is the greater and it is useless - forget it */
- }
- }
- }
- else{
- break;
- }
- }
-}
-
-void MergeRelativePath( char *out, const char *absolute, const char *relative ){
- const char *endpos = absolute + strlen( absolute );
- while ( endpos != absolute && ( endpos[-1] == '/' || endpos[-1] == '\\' ) )
- --endpos;
- while ( relative[0] == '.' && relative[1] == '.' && ( relative[2] == '/' || relative[2] == '\\' ) )
- {
- relative += 3;
- while ( endpos != absolute )
- {
- --endpos;
- if ( *endpos == '/' || *endpos == '\\' ) {
- break;
- }
- }
- while ( endpos != absolute && ( endpos[-1] == '/' || endpos[-1] == '\\' ) )
- --endpos;
- }
- memcpy( out, absolute, endpos - absolute );
- out[endpos - absolute] = '/';
- strcpy( out + ( endpos - absolute + 1 ), relative );
-}
-
-int MiniMapBSPMain( int argc, char **argv ){
- char minimapFilename[1024];
- char basename[1024];
- char path[1024];
- char relativeMinimapFilename[1024];
- qboolean autolevel;
- float minimapSharpen;
- float border;
- byte *data4b, *p;
- float *q;
- int x, y;
- int i;
- miniMapMode_t mode;
- vec3_t mins, maxs;
- qboolean keepaspect;
-
- /* arg checking */
- if ( argc < 2 ) {
- Sys_Printf( "Usage: q3map [-v] -minimap [-size n] [-sharpen f] [-samples n | -random n] [-o filename.tga] [-minmax Xmin Ymin Zmin Xmax Ymax Zmax] <mapname>\n" );
- return 0;
- }
-
- /* load the BSP first */
- strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
- StripExtension( source );
- DefaultExtension( source, ".bsp" );
- Sys_Printf( "Loading %s\n", source );
- BeginMapShaderFile( source );
- LoadShaderInfo();
- LoadBSPFile( source );
-
- minimap.model = &bspModels[0];
- VectorCopy( minimap.model->mins, mins );
- VectorCopy( minimap.model->maxs, maxs );
-
- *minimapFilename = 0;
- minimapSharpen = game->miniMapSharpen;
- minimap.width = minimap.height = game->miniMapSize;
- border = game->miniMapBorder;
- keepaspect = game->miniMapKeepAspect;
- mode = game->miniMapMode;
-
- autolevel = qfalse;
- minimap.samples = 1;
- minimap.sample_offsets = NULL;
- minimap.boost = 1.0;
- minimap.brightness = 0.0;
- minimap.contrast = 1.0;
-
- /* process arguments */
- for ( i = 1; i < ( argc - 1 ); i++ )
- {
- if ( !strcmp( argv[ i ], "-size" ) ) {
- minimap.width = minimap.height = atoi( argv[i + 1] );
- i++;
- Sys_Printf( "Image size set to %i\n", minimap.width );
- }
- else if ( !strcmp( argv[ i ], "-sharpen" ) ) {
- minimapSharpen = atof( argv[i + 1] );
- i++;
- Sys_Printf( "Sharpening coefficient set to %f\n", minimapSharpen );
- }
- else if ( !strcmp( argv[ i ], "-samples" ) ) {
- minimap.samples = atoi( argv[i + 1] );
- i++;
- Sys_Printf( "Samples set to %i\n", minimap.samples );
- if ( minimap.sample_offsets ) {
- free( minimap.sample_offsets );
- }
- minimap.sample_offsets = malloc( 2 * sizeof( *minimap.sample_offsets ) * minimap.samples );
- MiniMapMakeSampleOffsets();
- }
- else if ( !strcmp( argv[ i ], "-random" ) ) {
- minimap.samples = atoi( argv[i + 1] );
- i++;
- Sys_Printf( "Random samples set to %i\n", minimap.samples );
- if ( minimap.sample_offsets ) {
- free( minimap.sample_offsets );
- }
- minimap.sample_offsets = NULL;
- }
- else if ( !strcmp( argv[ i ], "-border" ) ) {
- border = atof( argv[i + 1] );
- i++;
- Sys_Printf( "Border set to %f\n", border );
- }
- else if ( !strcmp( argv[ i ], "-keepaspect" ) ) {
- keepaspect = qtrue;
- Sys_Printf( "Keeping aspect ratio by letterboxing\n", border );
- }
- else if ( !strcmp( argv[ i ], "-nokeepaspect" ) ) {
- keepaspect = qfalse;
- Sys_Printf( "Not keeping aspect ratio\n", border );
- }
- else if ( !strcmp( argv[ i ], "-o" ) ) {
- strcpy( minimapFilename, argv[i + 1] );
- i++;
- Sys_Printf( "Output file name set to %s\n", minimapFilename );
- }
- else if ( !strcmp( argv[ i ], "-minmax" ) && i < ( argc - 7 ) ) {
- mins[0] = atof( argv[i + 1] );
- mins[1] = atof( argv[i + 2] );
- mins[2] = atof( argv[i + 3] );
- maxs[0] = atof( argv[i + 4] );
- maxs[1] = atof( argv[i + 5] );
- maxs[2] = atof( argv[i + 6] );
- i += 6;
- Sys_Printf( "Map mins/maxs overridden\n" );
- }
- else if ( !strcmp( argv[ i ], "-gray" ) ) {
- mode = MINIMAP_MODE_GRAY;
- Sys_Printf( "Writing as white-on-black image\n" );
- }
- else if ( !strcmp( argv[ i ], "-black" ) ) {
- mode = MINIMAP_MODE_BLACK;
- Sys_Printf( "Writing as black alpha image\n" );
- }
- else if ( !strcmp( argv[ i ], "-white" ) ) {
- mode = MINIMAP_MODE_WHITE;
- Sys_Printf( "Writing as white alpha image\n" );
- }
- else if ( !strcmp( argv[ i ], "-boost" ) && i < ( argc - 2 ) ) {
- minimap.boost = atof( argv[i + 1] );
- i++;
- Sys_Printf( "Contrast boost set to %f\n", minimap.boost );
- }
- else if ( !strcmp( argv[ i ], "-brightness" ) && i < ( argc - 2 ) ) {
- minimap.brightness = atof( argv[i + 1] );
- i++;
- Sys_Printf( "Brightness set to %f\n", minimap.brightness );
- }
- else if ( !strcmp( argv[ i ], "-contrast" ) && i < ( argc - 2 ) ) {
- minimap.contrast = atof( argv[i + 1] );
- i++;
- Sys_Printf( "Contrast set to %f\n", minimap.contrast );
- }
- else if ( !strcmp( argv[ i ], "-autolevel" ) ) {
- autolevel = qtrue;
- Sys_Printf( "Auto level enabled\n", border );
- }
- else if ( !strcmp( argv[ i ], "-noautolevel" ) ) {
- autolevel = qfalse;
- Sys_Printf( "Auto level disabled\n", border );
- }
- }
-
- MiniMapMakeMinsMaxs( mins, maxs, border, keepaspect );
-
- if ( !*minimapFilename ) {
- ExtractFileBase( source, basename );
- ExtractFilePath( source, path );
- sprintf( relativeMinimapFilename, game->miniMapNameFormat, basename );
- MergeRelativePath( minimapFilename, path, relativeMinimapFilename );
- Sys_Printf( "Output file name automatically set to %s\n", minimapFilename );
- }
- ExtractFilePath( minimapFilename, path );
- Q_mkdir( path );
-
- if ( minimapSharpen >= 0 ) {
- minimap.sharpen_centermult = 8 * minimapSharpen + 1;
- minimap.sharpen_boxmult = -minimapSharpen;
- }
-
- minimap.data1f = safe_malloc( minimap.width * minimap.height * sizeof( *minimap.data1f ) );
- data4b = safe_malloc( minimap.width * minimap.height * 4 );
- if ( minimapSharpen >= 0 ) {
- minimap.sharpendata1f = safe_malloc( minimap.width * minimap.height * sizeof( *minimap.data1f ) );
- }
-
- MiniMapSetupBrushes();
-
- if ( minimap.samples <= 1 ) {
- Sys_Printf( "\n--- MiniMapNoSupersampling (%d) ---\n", minimap.height );
- RunThreadsOnIndividual( minimap.height, qtrue, MiniMapNoSupersampling );
- }
- else
- {
- if ( minimap.sample_offsets ) {
- Sys_Printf( "\n--- MiniMapSupersampled (%d) ---\n", minimap.height );
- RunThreadsOnIndividual( minimap.height, qtrue, MiniMapSupersampled );
- }
- else
- {
- Sys_Printf( "\n--- MiniMapRandomlySupersampled (%d) ---\n", minimap.height );
- RunThreadsOnIndividual( minimap.height, qtrue, MiniMapRandomlySupersampled );
- }
- }
-
- if ( minimap.boost != 1.0 ) {
- Sys_Printf( "\n--- MiniMapContrastBoost (%d) ---\n", minimap.height );
- RunThreadsOnIndividual( minimap.height, qtrue, MiniMapContrastBoost );
- }
-
- if ( autolevel ) {
- Sys_Printf( "\n--- MiniMapAutoLevel (%d) ---\n", minimap.height );
- float mi = 1, ma = 0;
- float s, o;
-
- // TODO threads!
- q = minimap.data1f;
- for ( y = 0; y < minimap.height; ++y )
- for ( x = 0; x < minimap.width; ++x )
- {
- float v = *q++;
- if ( v < mi ) {
- mi = v;
- }
- if ( v > ma ) {
- ma = v;
- }
- }
- if ( ma > mi ) {
- s = 1 / ( ma - mi );
- o = mi / ( ma - mi );
-
- // equations:
- // brightness + contrast * v
- // after autolevel:
- // brightness + contrast * (v * s - o)
- // =
- // (brightness - contrast * o) + (contrast * s) * v
- minimap.brightness = minimap.brightness - minimap.contrast * o;
- minimap.contrast *= s;
-
- Sys_Printf( "Auto level: Brightness changed to %f\n", minimap.brightness );
- Sys_Printf( "Auto level: Contrast changed to %f\n", minimap.contrast );
- }
- else{
- Sys_Printf( "Auto level: failed because all pixels are the same value\n" );
- }
- }
-
- if ( minimap.brightness != 0 || minimap.contrast != 1 ) {
- Sys_Printf( "\n--- MiniMapBrightnessContrast (%d) ---\n", minimap.height );
- RunThreadsOnIndividual( minimap.height, qtrue, MiniMapBrightnessContrast );
- }
-
- if ( minimap.sharpendata1f ) {
- Sys_Printf( "\n--- MiniMapSharpen (%d) ---\n", minimap.height );
- RunThreadsOnIndividual( minimap.height, qtrue, MiniMapSharpen );
- q = minimap.sharpendata1f;
- }
- else
- {
- q = minimap.data1f;
- }
-
- Sys_Printf( "\nConverting..." );
-
- switch ( mode )
- {
- case MINIMAP_MODE_GRAY:
- p = data4b;
- for ( y = 0; y < minimap.height; ++y )
- for ( x = 0; x < minimap.width; ++x )
- {
- byte b;
- float v = *q++;
- if ( v < 0 ) {
- v = 0;
- }
- if ( v > 255.0 / 256.0 ) {
- v = 255.0 / 256.0;
- }
- b = v * 256;
- *p++ = b;
- }
- Sys_Printf( " writing to %s...", minimapFilename );
- WriteTGAGray( minimapFilename, data4b, minimap.width, minimap.height );
- break;
- case MINIMAP_MODE_BLACK:
- p = data4b;
- for ( y = 0; y < minimap.height; ++y )
- for ( x = 0; x < minimap.width; ++x )
- {
- byte b;
- float v = *q++;
- if ( v < 0 ) {
- v = 0;
- }
- if ( v > 255.0 / 256.0 ) {
- v = 255.0 / 256.0;
- }
- b = v * 256;
- *p++ = 0;
- *p++ = 0;
- *p++ = 0;
- *p++ = b;
- }
- Sys_Printf( " writing to %s...", minimapFilename );
- WriteTGA( minimapFilename, data4b, minimap.width, minimap.height );
- break;
- case MINIMAP_MODE_WHITE:
- p = data4b;
- for ( y = 0; y < minimap.height; ++y )
- for ( x = 0; x < minimap.width; ++x )
- {
- byte b;
- float v = *q++;
- if ( v < 0 ) {
- v = 0;
- }
- if ( v > 255.0 / 256.0 ) {
- v = 255.0 / 256.0;
- }
- b = v * 256;
- *p++ = 255;
- *p++ = 255;
- *p++ = 255;
- *p++ = b;
- }
- Sys_Printf( " writing to %s...", minimapFilename );
- WriteTGA( minimapFilename, data4b, minimap.width, minimap.height );
- break;
- }
-
- Sys_Printf( " done.\n" );
-
- /* return to sender */
- return 0;
-}
-
-
-
-
-
-/*
- MD4BlockChecksum()
- calculates an md4 checksum for a block of data
- */
-
-static int MD4BlockChecksum( void *buffer, int length ){
- return Com_BlockChecksum( buffer, length );
-}
-
-/*
- FixAAS()
- resets an aas checksum to match the given BSP
- */
-
-int FixAAS( int argc, char **argv ){
- int length, checksum;
- void *buffer;
- FILE *file;
- char aas[ 1024 ], **ext;
- char *exts[] =
- {
- ".aas",
- "_b0.aas",
- "_b1.aas",
- NULL
- };
-
-
- /* arg checking */
- if ( argc < 2 ) {
- Sys_Printf( "Usage: q3map -fixaas [-v] <mapname>\n" );
- return 0;
- }
-
- /* do some path mangling */
- strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
- StripExtension( source );
- DefaultExtension( source, ".bsp" );
-
- /* note it */
- Sys_Printf( "--- FixAAS ---\n" );
-
- /* load the bsp */
- Sys_Printf( "Loading %s\n", source );
- length = LoadFile( source, &buffer );
-
- /* create bsp checksum */
- Sys_Printf( "Creating checksum...\n" );
- checksum = LittleLong( MD4BlockChecksum( buffer, length ) );
-
- /* write checksum to aas */
- ext = exts;
- while ( *ext )
- {
- /* mangle name */
- strcpy( aas, source );
- StripExtension( aas );
- strcat( aas, *ext );
- Sys_Printf( "Trying %s\n", aas );
- ext++;
-
- /* fix it */
- file = fopen( aas, "r+b" );
- if ( !file ) {
- continue;
- }
- if ( fwrite( &checksum, 4, 1, file ) != 1 ) {
- Error( "Error writing checksum to %s", aas );
- }
- fclose( file );
- }
-
- /* return to sender */
- return 0;
-}
-
-
-
-/*
- AnalyzeBSP() - ydnar
- analyzes a Quake engine BSP file
- */
-
-typedef struct abspHeader_s
-{
- char ident[ 4 ];
- int version;
-
- bspLump_t lumps[ 1 ]; /* unknown size */
-}
-abspHeader_t;
-
-typedef struct abspLumpTest_s
-{
- int radix, minCount;
- char *name;
-}
-abspLumpTest_t;
-
-int AnalyzeBSP( int argc, char **argv ){
- abspHeader_t *header;
- int size, i, version, offset, length, lumpInt, count;
- char ident[ 5 ];
- void *lump;
- float lumpFloat;
- char lumpString[ 1024 ], source[ 1024 ];
- qboolean lumpSwap = qfalse;
- abspLumpTest_t *lumpTest;
- static abspLumpTest_t lumpTests[] =
- {
- { sizeof( bspPlane_t ), 6, "IBSP LUMP_PLANES" },
- { sizeof( bspBrush_t ), 1, "IBSP LUMP_BRUSHES" },
- { 8, 6, "IBSP LUMP_BRUSHSIDES" },
- { sizeof( bspBrushSide_t ), 6, "RBSP LUMP_BRUSHSIDES" },
- { sizeof( bspModel_t ), 1, "IBSP LUMP_MODELS" },
- { sizeof( bspNode_t ), 2, "IBSP LUMP_NODES" },
- { sizeof( bspLeaf_t ), 1, "IBSP LUMP_LEAFS" },
- { 104, 3, "IBSP LUMP_DRAWSURFS" },
- { 44, 3, "IBSP LUMP_DRAWVERTS" },
- { 4, 6, "IBSP LUMP_DRAWINDEXES" },
- { 128 * 128 * 3, 1, "IBSP LUMP_LIGHTMAPS" },
- { 256 * 256 * 3, 1, "IBSP LUMP_LIGHTMAPS (256 x 256)" },
- { 512 * 512 * 3, 1, "IBSP LUMP_LIGHTMAPS (512 x 512)" },
- { 0, 0, NULL }
- };
-
-
- /* arg checking */
- if ( argc < 1 ) {
- Sys_Printf( "Usage: q3map -analyze [-lumpswap] [-v] <mapname>\n" );
- return 0;
- }
-
- /* process arguments */
- for ( i = 1; i < ( argc - 1 ); i++ )
- {
- /* -format map|ase|... */
- if ( !strcmp( argv[ i ], "-lumpswap" ) ) {
- Sys_Printf( "Swapped lump structs enabled\n" );
- lumpSwap = qtrue;
- }
- }
-
- /* clean up map name */
- strcpy( source, ExpandArg( argv[ i ] ) );
- Sys_Printf( "Loading %s\n", source );
-
- /* load the file */
- size = LoadFile( source, (void**) &header );
- if ( size == 0 || header == NULL ) {
- Sys_Printf( "Unable to load %s.\n", source );
- return -1;
- }
-
- /* analyze ident/version */
- memcpy( ident, header->ident, 4 );
- ident[ 4 ] = '\0';
- version = LittleLong( header->version );
-
- Sys_Printf( "Identity: %s\n", ident );
- Sys_Printf( "Version: %d\n", version );
- Sys_Printf( "---------------------------------------\n" );
-
- /* analyze each lump */
- for ( i = 0; i < 100; i++ )
- {
- /* call of duty swapped lump pairs */
- if ( lumpSwap ) {
- offset = LittleLong( header->lumps[ i ].length );
- length = LittleLong( header->lumps[ i ].offset );
- }
-
- /* standard lump pairs */
- else
- {
- offset = LittleLong( header->lumps[ i ].offset );
- length = LittleLong( header->lumps[ i ].length );
- }
-
- /* extract data */
- lump = (byte*) header + offset;
- lumpInt = LittleLong( (int) *( (int*) lump ) );
- lumpFloat = LittleFloat( (float) *( (float*) lump ) );
- memcpy( lumpString, (char*) lump, ( (size_t)length < sizeof( lumpString ) ? (size_t)length : sizeof( lumpString ) - 1 ) );
- lumpString[ sizeof( lumpString ) - 1 ] = '\0';
-
- /* print basic lump info */
- Sys_Printf( "Lump: %d\n", i );
- Sys_Printf( "Offset: %d bytes\n", offset );
- Sys_Printf( "Length: %d bytes\n", length );
-
- /* only operate on valid lumps */
- if ( length > 0 ) {
- /* print data in 4 formats */
- Sys_Printf( "As hex: %08X\n", lumpInt );
- Sys_Printf( "As int: %d\n", lumpInt );
- Sys_Printf( "As float: %f\n", lumpFloat );
- Sys_Printf( "As string: %s\n", lumpString );
-
- /* guess lump type */
- if ( lumpString[ 0 ] == '{' && lumpString[ 2 ] == '"' ) {
- Sys_Printf( "Type guess: IBSP LUMP_ENTITIES\n" );
- }
- else if ( strstr( lumpString, "textures/" ) ) {
- Sys_Printf( "Type guess: IBSP LUMP_SHADERS\n" );
- }
- else
- {
- /* guess based on size/count */
- for ( lumpTest = lumpTests; lumpTest->radix > 0; lumpTest++ )
- {
- if ( ( length % lumpTest->radix ) != 0 ) {
- continue;
- }
- count = length / lumpTest->radix;
- if ( count < lumpTest->minCount ) {
- continue;
- }
- Sys_Printf( "Type guess: %s (%d x %d)\n", lumpTest->name, count, lumpTest->radix );
- }
- }
- }
-
- Sys_Printf( "---------------------------------------\n" );
-
- /* end of file */
- if ( offset + length >= size ) {
- break;
- }
- }
-
- /* last stats */
- Sys_Printf( "Lump count: %d\n", i + 1 );
- Sys_Printf( "File size: %d bytes\n", size );
-
- /* return to caller */
- return 0;
-}
-
-
+#include <glib.h>
/*
- BSPInfo()
- emits statistics about the bsp file
+ Random()
+ returns a pseudorandom number between 0 and 1
*/
-int BSPInfo( int count, char **fileNames ){
- int i;
- char source[ 1024 ], ext[ 64 ];
- int size;
- FILE *f;
-
-
- /* dummy check */
- if ( count < 1 ) {
- Sys_Printf( "No files to dump info for.\n" );
- return -1;
- }
-
- /* enable info mode */
- infoMode = qtrue;
-
- /* walk file list */
- for ( i = 0; i < count; i++ )
- {
- Sys_Printf( "---------------------------------\n" );
-
- /* mangle filename and get size */
- strcpy( source, fileNames[ i ] );
- ExtractFileExtension( source, ext );
- if ( !Q_stricmp( ext, "map" ) ) {
- StripExtension( source );
- }
- DefaultExtension( source, ".bsp" );
- f = fopen( source, "rb" );
- if ( f ) {
- size = Q_filelength( f );
- fclose( f );
- }
- else{
- size = 0;
- }
-
- /* load the bsp file and print lump sizes */
- Sys_Printf( "%s\n", source );
- LoadBSPFile( source );
- PrintBSPFileSizes();
-
- /* print sizes */
- Sys_Printf( "\n" );
- Sys_Printf( " total %9d\n", size );
- Sys_Printf( " %9d KB\n", size / 1024 );
- Sys_Printf( " %9d MB\n", size / ( 1024 * 1024 ) );
-
- Sys_Printf( "---------------------------------\n" );
- }
-
- /* return count */
- return i;
+vec_t Random( void ){
+ return (vec_t) rand() / RAND_MAX;
}
-static void ExtrapolateTexcoords( const float *axyz, const float *ast, const float *bxyz, const float *bst, const float *cxyz, const float *cst, const float *axyz_new, float *ast_out, const float *bxyz_new, float *bst_out, const float *cxyz_new, float *cst_out ){
- vec4_t scoeffs, tcoeffs;
- float md;
- m4x4_t solvematrix;
-
- vec3_t norm;
- vec3_t dab, dac;
- VectorSubtract( bxyz, axyz, dab );
- VectorSubtract( cxyz, axyz, dac );
- CrossProduct( dab, dac, norm );
-
- // assume:
- // s = f(x, y, z)
- // s(v + norm) = s(v) when n ortho xyz
-
- // s(v) = DotProduct(v, scoeffs) + scoeffs[3]
-
- // solve:
- // scoeffs * (axyz, 1) == ast[0]
- // scoeffs * (bxyz, 1) == bst[0]
- // scoeffs * (cxyz, 1) == cst[0]
- // scoeffs * (norm, 0) == 0
- // scoeffs * [axyz, 1 | bxyz, 1 | cxyz, 1 | norm, 0] = [ast[0], bst[0], cst[0], 0]
- solvematrix[0] = axyz[0];
- solvematrix[4] = axyz[1];
- solvematrix[8] = axyz[2];
- solvematrix[12] = 1;
- solvematrix[1] = bxyz[0];
- solvematrix[5] = bxyz[1];
- solvematrix[9] = bxyz[2];
- solvematrix[13] = 1;
- solvematrix[2] = cxyz[0];
- solvematrix[6] = cxyz[1];
- solvematrix[10] = cxyz[2];
- solvematrix[14] = 1;
- solvematrix[3] = norm[0];
- solvematrix[7] = norm[1];
- solvematrix[11] = norm[2];
- solvematrix[15] = 0;
-
- md = m4_det( solvematrix );
- if ( md * md < 1e-10 ) {
- Sys_Printf( "Cannot invert some matrix, some texcoords aren't extrapolated!" );
- return;
+char *Q_strncpyz( char *dst, const char *src, size_t len ) {
+ if ( len == 0 ) {
+ abort();
}
- m4x4_invert( solvematrix );
-
- scoeffs[0] = ast[0];
- scoeffs[1] = bst[0];
- scoeffs[2] = cst[0];
- scoeffs[3] = 0;
- m4x4_transform_vec4( solvematrix, scoeffs );
- tcoeffs[0] = ast[1];
- tcoeffs[1] = bst[1];
- tcoeffs[2] = cst[1];
- tcoeffs[3] = 0;
- m4x4_transform_vec4( solvematrix, tcoeffs );
-
- ast_out[0] = scoeffs[0] * axyz_new[0] + scoeffs[1] * axyz_new[1] + scoeffs[2] * axyz_new[2] + scoeffs[3];
- ast_out[1] = tcoeffs[0] * axyz_new[0] + tcoeffs[1] * axyz_new[1] + tcoeffs[2] * axyz_new[2] + tcoeffs[3];
- bst_out[0] = scoeffs[0] * bxyz_new[0] + scoeffs[1] * bxyz_new[1] + scoeffs[2] * bxyz_new[2] + scoeffs[3];
- bst_out[1] = tcoeffs[0] * bxyz_new[0] + tcoeffs[1] * bxyz_new[1] + tcoeffs[2] * bxyz_new[2] + tcoeffs[3];
- cst_out[0] = scoeffs[0] * cxyz_new[0] + scoeffs[1] * cxyz_new[1] + scoeffs[2] * cxyz_new[2] + scoeffs[3];
- cst_out[1] = tcoeffs[0] * cxyz_new[0] + tcoeffs[1] * cxyz_new[1] + tcoeffs[2] * cxyz_new[2] + tcoeffs[3];
+ strncpy( dst, src, len );
+ dst[ len - 1 ] = '\0';
+ return dst;
}
-/*
- ScaleBSPMain()
- amaze and confuse your enemies with wierd scaled maps!
- */
-
-int ScaleBSPMain( int argc, char **argv ){
- int i, j;
- float f, a;
- vec3_t scale;
- vec3_t vec;
- char str[ 1024 ];
- int uniform, axis;
- qboolean texscale;
- float *old_xyzst = NULL;
- float spawn_ref = 0;
-
-
- /* arg checking */
- if ( argc < 3 ) {
- Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
- return 0;
- }
-
- texscale = qfalse;
- for ( i = 1; i < argc - 2; ++i )
- {
- if ( !strcmp( argv[i], "-tex" ) ) {
- texscale = qtrue;
- }
- else if ( !strcmp( argv[i], "-spawn_ref" ) ) {
- spawn_ref = atof( argv[i + 1] );
- ++i;
- }
- else{
- break;
- }
- }
-
- /* get scale */
- // if(argc-2 >= i) // always true
- scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
- if ( argc - 3 >= i ) {
- scale[1] = scale[0] = atof( argv[ argc - 3 ] );
- }
- if ( argc - 4 >= i ) {
- scale[0] = atof( argv[ argc - 4 ] );
- }
-
- uniform = ( ( scale[0] == scale[1] ) && ( scale[1] == scale[2] ) );
-
- if ( scale[0] == 0.0f || scale[1] == 0.0f || scale[2] == 0.0f ) {
- Sys_Printf( "Usage: q3map [-v] -scale [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
- Sys_Printf( "Non-zero scale value required.\n" );
- return 0;
- }
-
- /* do some path mangling */
- strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
- StripExtension( source );
- DefaultExtension( source, ".bsp" );
-
- /* load the bsp */
- Sys_Printf( "Loading %s\n", source );
- LoadBSPFile( source );
- ParseEntities();
-
- /* note it */
- Sys_Printf( "--- ScaleBSP ---\n" );
- Sys_FPrintf( SYS_VRB, "%9d entities\n", numEntities );
-
- /* scale entity keys */
- for ( i = 0; i < numBSPEntities && i < numEntities; i++ )
- {
- /* scale origin */
- GetVectorForKey( &entities[ i ], "origin", vec );
- if ( ( vec[ 0 ] || vec[ 1 ] || vec[ 2 ] ) ) {
- if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
- vec[2] += spawn_ref;
- }
- vec[0] *= scale[0];
- vec[1] *= scale[1];
- vec[2] *= scale[2];
- if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
- vec[2] -= spawn_ref;
- }
- sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
- SetKeyValue( &entities[ i ], "origin", str );
- }
-
- a = FloatForKey( &entities[ i ], "angle" );
- if ( a == -1 || a == -2 ) { // z scale
- axis = 2;
- }
- else if ( fabs( sin( DEG2RAD( a ) ) ) < 0.707 ) {
- axis = 0;
- }
- else{
- axis = 1;
- }
-
- /* scale door lip */
- f = FloatForKey( &entities[ i ], "lip" );
- if ( f ) {
- f *= scale[axis];
- sprintf( str, "%f", f );
- SetKeyValue( &entities[ i ], "lip", str );
- }
- /* scale plat height */
- f = FloatForKey( &entities[ i ], "height" );
- if ( f ) {
- f *= scale[2];
- sprintf( str, "%f", f );
- SetKeyValue( &entities[ i ], "height", str );
- }
+char *Q_strcat( char *dst, size_t dlen, const char *src ) {
- size_t n = strlen( dst );
++ size_t n = strlen( dst );
- // TODO maybe allow a definition file for entities to specify which values are scaled how?
+ if ( n > dlen ) {
+ abort(); /* buffer overflow */
}
- /* scale models */
- for ( i = 0; i < numBSPModels; i++ )
- {
- bspModels[ i ].mins[0] *= scale[0];
- bspModels[ i ].mins[1] *= scale[1];
- bspModels[ i ].mins[2] *= scale[2];
- bspModels[ i ].maxs[0] *= scale[0];
- bspModels[ i ].maxs[1] *= scale[1];
- bspModels[ i ].maxs[2] *= scale[2];
- }
+ return Q_strncpyz( dst + n, src, dlen - n );
+}
- /* scale nodes */
- for ( i = 0; i < numBSPNodes; i++ )
- {
- bspNodes[ i ].mins[0] *= scale[0];
- bspNodes[ i ].mins[1] *= scale[1];
- bspNodes[ i ].mins[2] *= scale[2];
- bspNodes[ i ].maxs[0] *= scale[0];
- bspNodes[ i ].maxs[1] *= scale[1];
- bspNodes[ i ].maxs[2] *= scale[2];
- }
- /* scale leafs */
- for ( i = 0; i < numBSPLeafs; i++ )
- {
- bspLeafs[ i ].mins[0] *= scale[0];
- bspLeafs[ i ].mins[1] *= scale[1];
- bspLeafs[ i ].mins[2] *= scale[2];
- bspLeafs[ i ].maxs[0] *= scale[0];
- bspLeafs[ i ].maxs[1] *= scale[1];
- bspLeafs[ i ].maxs[2] *= scale[2];
- }
+char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen ) {
+ size_t n = strlen( dst );
- if ( texscale ) {
- Sys_Printf( "Using texture unlocking (and probably breaking texture alignment a lot)\n" );
- old_xyzst = safe_malloc( sizeof( *old_xyzst ) * numBSPDrawVerts * 5 );
- for ( i = 0; i < numBSPDrawVerts; i++ )
- {
- old_xyzst[5 * i + 0] = bspDrawVerts[i].xyz[0];
- old_xyzst[5 * i + 1] = bspDrawVerts[i].xyz[1];
- old_xyzst[5 * i + 2] = bspDrawVerts[i].xyz[2];
- old_xyzst[5 * i + 3] = bspDrawVerts[i].st[0];
- old_xyzst[5 * i + 4] = bspDrawVerts[i].st[1];
- }
+ if ( n > dlen ) {
+ abort(); /* buffer overflow */
}
- /* scale drawverts */
- for ( i = 0; i < numBSPDrawVerts; i++ )
- {
- bspDrawVerts[i].xyz[0] *= scale[0];
- bspDrawVerts[i].xyz[1] *= scale[1];
- bspDrawVerts[i].xyz[2] *= scale[2];
- bspDrawVerts[i].normal[0] /= scale[0];
- bspDrawVerts[i].normal[1] /= scale[1];
- bspDrawVerts[i].normal[2] /= scale[2];
- VectorNormalize( bspDrawVerts[i].normal, bspDrawVerts[i].normal );
- }
+ return Q_strncpyz( dst + n, src, MIN( slen, dlen - n ) );
+}
- if ( texscale ) {
- for ( i = 0; i < numBSPDrawSurfaces; i++ )
- {
- switch ( bspDrawSurfaces[i].surfaceType )
- {
- case SURFACE_FACE:
- case SURFACE_META:
- if ( bspDrawSurfaces[i].numIndexes % 3 ) {
- Error( "Not a triangulation!" );
- }
- for ( j = bspDrawSurfaces[i].firstIndex; j < bspDrawSurfaces[i].firstIndex + bspDrawSurfaces[i].numIndexes; j += 3 )
- {
- int ia = bspDrawIndexes[j] + bspDrawSurfaces[i].firstVert, ib = bspDrawIndexes[j + 1] + bspDrawSurfaces[i].firstVert, ic = bspDrawIndexes[j + 2] + bspDrawSurfaces[i].firstVert;
- bspDrawVert_t *a = &bspDrawVerts[ia], *b = &bspDrawVerts[ib], *c = &bspDrawVerts[ic];
- float *oa = &old_xyzst[ia * 5], *ob = &old_xyzst[ib * 5], *oc = &old_xyzst[ic * 5];
- // extrapolate:
- // a->xyz -> oa
- // b->xyz -> ob
- // c->xyz -> oc
- ExtrapolateTexcoords(
- &oa[0], &oa[3],
- &ob[0], &ob[3],
- &oc[0], &oc[3],
- a->xyz, a->st,
- b->xyz, b->st,
- c->xyz, c->st );
- }
- break;
- }
- }
- }
- /* scale planes */
- if ( uniform ) {
- for ( i = 0; i < numBSPPlanes; i++ )
- {
- bspPlanes[ i ].dist *= scale[0];
- }
- }
- else
- {
- for ( i = 0; i < numBSPPlanes; i++ )
- {
- bspPlanes[ i ].normal[0] /= scale[0];
- bspPlanes[ i ].normal[1] /= scale[1];
- bspPlanes[ i ].normal[2] /= scale[2];
- f = 1 / VectorLength( bspPlanes[i].normal );
- VectorScale( bspPlanes[i].normal, f, bspPlanes[i].normal );
- bspPlanes[ i ].dist *= f;
- }
- }
+/*
+ ExitQ3Map()
+ cleanup routine
+ */
- /* scale gridsize */
- GetVectorForKey( &entities[ 0 ], "gridsize", vec );
- if ( ( vec[ 0 ] + vec[ 1 ] + vec[ 2 ] ) == 0.0f ) {
- VectorCopy( gridSize, vec );
+static void ExitQ3Map( void ){
+ BSPFilesCleanup();
+ if ( mapDrawSurfs != NULL ) {
+ free( mapDrawSurfs );
}
- vec[0] *= scale[0];
- vec[1] *= scale[1];
- vec[2] *= scale[2];
- sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
- SetKeyValue( &entities[ 0 ], "gridsize", str );
-
- /* inject command line parameters */
- InjectCommandLine( argv, 0, argc - 1 );
-
- /* write the bsp */
- UnparseEntities();
- StripExtension( source );
- DefaultExtension( source, "_s.bsp" );
- Sys_Printf( "Writing %s\n", source );
- WriteBSPFile( source );
-
- /* return to sender */
- return 0;
}
/*
ShiftBSPMain()
- shifts a map: works correctly only with axial faces, placed in positive half of axis
- for testing physics with huge coordinates
+ shifts a map: for testing physics with huge coordinates
*/
int ShiftBSPMain( int argc, char **argv ){
-/*
- PseudoCompileBSP()
- a stripped down ProcessModels
- */
-void PseudoCompileBSP( qboolean need_tree ){
- int models;
- char modelValue[10];
- entity_t *entity;
- face_t *faces;
- tree_t *tree;
- node_t *node;
- brush_t *brush;
- side_t *side;
- int i;
-
- SetDrawSurfacesBuffer();
- mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
- memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
- numMapDrawSurfs = 0;
-
- BeginBSPFile();
- models = 1;
- for ( mapEntityNum = 0; mapEntityNum < numEntities; mapEntityNum++ )
- {
- /* get entity */
- entity = &entities[ mapEntityNum ];
- if ( entity->brushes == NULL && entity->patches == NULL ) {
- continue;
- }
-
- if ( mapEntityNum != 0 ) {
- sprintf( modelValue, "*%d", models++ );
- SetKeyValue( entity, "model", modelValue );
- }
-
- /* process the model */
- Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
- BeginModel();
-
- entity->firstDrawSurf = numMapDrawSurfs;
-
- ClearMetaTriangles();
- PatchMapDrawSurfs( entity );
-
- if ( mapEntityNum == 0 && need_tree ) {
- faces = MakeStructuralBSPFaceList( entities[0].brushes );
- tree = FaceBSP( faces );
- node = tree->headnode;
- }
- else
- {
- node = AllocNode();
- node->planenum = PLANENUM_LEAF;
- tree = AllocTree();
- tree->headnode = node;
- }
-
- /* a minimized ClipSidesIntoTree */
- for ( brush = entity->brushes; brush; brush = brush->next )
- {
- /* walk the brush sides */
- for ( i = 0; i < brush->numsides; i++ )
- {
- /* get side */
- side = &brush->sides[ i ];
- if ( side->winding == NULL ) {
- continue;
- }
- /* shader? */
- if ( side->shaderInfo == NULL ) {
- continue;
- }
- /* save this winding as a visible surface */
- DrawSurfaceForSide( entity, brush, side, side->winding );
- }
- }
-
- if ( meta ) {
- ClassifyEntitySurfaces( entity );
- MakeEntityDecals( entity );
- MakeEntityMetaTriangles( entity );
- SmoothMetaTriangles();
- MergeMetaTriangles();
- }
- FilterDrawsurfsIntoTree( entity, tree );
-
- FilterStructuralBrushesIntoTree( entity, tree );
- FilterDetailBrushesIntoTree( entity, tree );
-
- EmitBrushes( entity->brushes, &entity->firstBrush, &entity->numBrushes );
- EndModel( entity, node );
- }
- EndBSPFile( qfalse );
-}
-
-/*
- ConvertBSPMain()
- main argument processing function for bsp conversion
- */
-
-int ConvertBSPMain( int argc, char **argv ){
- int i;
- int ( *convertFunc )( char * );
- game_t *convertGame;
- char ext[1024];
- qboolean map_allowed, force_bsp, force_map;
-
-
- /* set default */
- convertFunc = ConvertBSPToASE;
- convertGame = NULL;
- map_allowed = qfalse;
- force_bsp = qfalse;
- force_map = qfalse;
-
- /* arg checking */
- if ( argc < 1 ) {
- Sys_Printf( "Usage: q3map -convert [-format <ase|obj|map_bp|map>] [-shadersasbitmap|-lightmapsastexcoord|-deluxemapsastexcoord] [-readbsp|-readmap [-meta|-patchmeta]] [-v] <mapname>\n" );
- return 0;
- }
-
- /* process arguments */
- for ( i = 1; i < ( argc - 1 ); i++ )
- {
- /* -format map|ase|... */
- if ( !strcmp( argv[ i ], "-format" ) ) {
- i++;
- if ( !Q_stricmp( argv[ i ], "ase" ) ) {
- convertFunc = ConvertBSPToASE;
- map_allowed = qfalse;
- }
- else if ( !Q_stricmp( argv[ i ], "obj" ) ) {
- convertFunc = ConvertBSPToOBJ;
- map_allowed = qfalse;
- }
- else if ( !Q_stricmp( argv[ i ], "map_bp" ) ) {
- convertFunc = ConvertBSPToMap_BP;
- map_allowed = qtrue;
- }
- else if ( !Q_stricmp( argv[ i ], "map" ) ) {
- convertFunc = ConvertBSPToMap;
- map_allowed = qtrue;
- }
- else
- {
- convertGame = GetGame( argv[ i ] );
- map_allowed = qfalse;
- if ( convertGame == NULL ) {
- Sys_Printf( "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] );
- }
- }
- }
- else if ( !strcmp( argv[ i ], "-ne" ) ) {
- normalEpsilon = atof( argv[ i + 1 ] );
- i++;
- Sys_Printf( "Normal epsilon set to %f\n", normalEpsilon );
- }
- else if ( !strcmp( argv[ i ], "-de" ) ) {
- distanceEpsilon = atof( argv[ i + 1 ] );
- i++;
- Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon );
- }
- else if ( !strcmp( argv[ i ], "-shaderasbitmap" ) || !strcmp( argv[ i ], "-shadersasbitmap" ) ) {
- shadersAsBitmap = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-lightmapastexcoord" ) || !strcmp( argv[ i ], "-lightmapsastexcoord" ) ) {
- lightmapsAsTexcoord = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-deluxemapastexcoord" ) || !strcmp( argv[ i ], "-deluxemapsastexcoord" ) ) {
- lightmapsAsTexcoord = qtrue;
- deluxemap = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-readbsp" ) ) {
- force_bsp = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-readmap" ) ) {
- force_map = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-meta" ) ) {
- meta = qtrue;
- }
- else if ( !strcmp( argv[ i ], "-patchmeta" ) ) {
- meta = qtrue;
- patchMeta = qtrue;
- }
- }
-
- LoadShaderInfo();
-
- /* clean up map name */
- strcpy( source, ExpandArg( argv[i] ) );
- ExtractFileExtension( source, ext );
-
- if ( !map_allowed && !force_map ) {
- force_bsp = qtrue;
- }
-
- if ( force_map || ( !force_bsp && !Q_stricmp( ext, "map" ) && map_allowed ) ) {
- if ( !map_allowed ) {
- Sys_Printf( "WARNING: the requested conversion should not be done from .map files. Compile a .bsp first.\n" );
- }
- StripExtension( source );
- DefaultExtension( source, ".map" );
- Sys_Printf( "Loading %s\n", source );
- LoadMapFile( source, qfalse, convertGame == NULL );
- PseudoCompileBSP( convertGame != NULL );
- }
- else
- {
- StripExtension( source );
- DefaultExtension( source, ".bsp" );
- Sys_Printf( "Loading %s\n", source );
- LoadBSPFile( source );
- ParseEntities();
- }
-
- /* bsp format convert? */
- if ( convertGame != NULL ) {
- /* set global game */
- game = convertGame;
-
- /* write bsp */
- StripExtension( source );
- DefaultExtension( source, "_c.bsp" );
- Sys_Printf( "Writing %s\n", source );
- WriteBSPFile( source );
-
- /* return to sender */
- return 0;
- }
-
- /* normal convert */
- return convertFunc( source );
-}
-
-
-
/*
main()
q3map mojo...
int main( int argc, char **argv ){
int i, r;
double start, end;
+ extern qboolean werror;
/* we want consistent 'randomness' */
/* read general options first */
for ( i = 1; i < argc; i++ )
{
+ /* -help */
+ if ( !strcmp( argv[ i ], "-h" ) || !strcmp( argv[ i ], "--help" )
+ || !strcmp( argv[ i ], "-help" ) ) {
+ HelpMain(argv[i+1]);
+ return 0;
+ }
+
/* -connect */
if ( !strcmp( argv[ i ], "-connect" ) ) {
argv[ i ] = NULL;
argv[ i ] = NULL;
}
+ /* make all warnings into errors */
+ else if ( !strcmp( argv[ i ], "-werror" ) ) {
+ werror = qtrue;
+ argv[ i ] = NULL;
+ }
+
/* patch subdivisions */
else if ( !strcmp( argv[ i ], "-subdivisions" ) ) {
argv[ i ] = NULL;
numthreads = atoi( argv[ i ] );
argv[ i ] = NULL;
}
+
else if( !strcmp( argv[ i ], "-nocmdline" ) )
{
Sys_Printf( "noCmdLine\n" );
/* fixaas */
if ( !strcmp( argv[ 1 ], "-fixaas" ) ) {
- r = FixAAS( argc - 1, argv + 1 );
+ r = FixAASMain( argc - 1, argv + 1 );
}
/* analyze */
else if ( !strcmp( argv[ 1 ], "-analyze" ) ) {
- r = AnalyzeBSP( argc - 1, argv + 1 );
+ r = AnalyzeBSPMain( argc - 1, argv + 1 );
}
/* info */
else if ( !strcmp( argv[ 1 ], "-info" ) ) {
- r = BSPInfo( argc - 2, argv + 2 );
+ r = BSPInfoMain( argc - 2, argv + 2 );
}
/* vis */
/* vlight */
else if ( !strcmp( argv[ 1 ], "-vlight" ) ) {
- Sys_Printf( "WARNING: VLight is no longer supported, defaulting to -light -fast instead\n\n" );
+ Sys_FPrintf( SYS_WRN, "WARNING: VLight is no longer supported, defaulting to -light -fast instead\n\n" );
argv[ 1 ] = "-fast"; /* eek a hack */
r = LightMain( argc, argv );
}
+ /* QBall: export entities */
+ else if ( !strcmp( argv[ 1 ], "-exportents" ) ) {
+ r = ExportEntitiesMain( argc - 1, argv + 1 );
+ }
+
/* ydnar: lightmap export */
else if ( !strcmp( argv[ 1 ], "-export" ) ) {
r = ExportLightmapsMain( argc - 1, argv + 1 );
#ifndef Q3MAP2_H
#define Q3MAP2_H
-
+#include "globaldefs.h"
/* version */
#ifndef Q3MAP_VERSION
------------------------------------------------------------------------------- */
/* platform-specific */
-#if defined( __linux__ ) || defined( __APPLE__ )
+#if GDEF_OS_LINUX || GDEF_OS_MACOS
#define Q_UNIX
#endif
#include <limits.h>
#endif
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
#include <windows.h>
#endif
#include "mathlib.h"
#include "md5lib.h"
#include "ddslib.h"
+#ifdef BUILD_CRUNCH
+#include "crn_rgba.h"
+#endif // BUILD_CRUNCH
#include "picomodel.h"
------------------------------------------------------------------------------- */
#define MAC_STATIC_HACK 0
-#if defined( __APPLE__ ) && MAC_STATIC_HACK
+#if GDEF_OS_MACOS && MAC_STATIC_HACK
#define MAC_STATIC static
#else
#define MAC_STATIC
#endif
#if 1
- #ifdef WIN32
+ #if GDEF_OS_WINDOWS
#define Q_stricmp stricmp
#define Q_strncasecmp strnicmp
#else
/* ok to increase these at the expense of more memory */
#define MAX_MAP_AREAS 0x100 /* MAX_MAP_AREA_BYTES in q_shared must match! */
-#define MAX_MAP_FOGS 0x100 //& 0x100 /* RBSP (32 - world fog - goggles) */
+#define MAX_MAP_FOGS 30 //& 0x100 /* RBSP (32 - world fog - goggles) */
#define MAX_MAP_LEAFS 0x20000
#define MAX_MAP_PORTALS 0x20000
#define MAX_MAP_LIGHTING 0x800000
#define MAX_MAP_VISCLUSTERS 0x4000 // <= MAX_MAP_LEAFS
#define MAX_MAP_VISIBILITY ( VIS_HEADER_SIZE + MAX_MAP_VISCLUSTERS * ( ( ( MAX_MAP_VISCLUSTERS + 63 ) & ~63 ) >> 3 ) )
-#define MAX_MAP_DRAW_SURFS 0x20000
+#define MAX_MAP_DRAW_SURFS 0x20000
#define MAX_MAP_ADVERTISEMENTS 30
bspShader_t;
- /* planes x^1 is allways the opposite of plane x */
+ /* planes x^1 is always the opposite of plane x */
typedef struct
{
{
int planeNum;
int children[ 2 ]; /* negative numbers are -(leafs+1), not nodes */
- int mins[ 3 ]; /* for frustom culling */
+ int mins[ 3 ]; /* for frustum culling */
int maxs[ 3 ];
}
bspNode_t;
shaderInfo_t *shaderInfo;
shaderInfo_t *celShader; /* :) */
+ /* jal : entity based _lightmapsamplesize */
+ int lightmapSampleSize;
/* ydnar: gs mods */
- int lightmapSampleSize; /* jal : entity based _lightmapsamplesize */
float lightmapScale;
vec3_t eMins, eMaxs;
indexMap_t *im;
char *Q_strncpyz( char *dst, const char *src, size_t len );
char *Q_strcat( char *dst, size_t dlen, const char *src );
char *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen );
-int BSPInfo( int count, char **fileNames );
-int ScaleBSPMain( int argc, char **argv );
int ShiftBSPMain( int argc, char **argv );
-int ConvertMain( int argc, char **argv );
+/* help.c */
+void HelpMain(const char* arg);
/* path_init.c */
game_t *GetGame( char *arg );
void InitPaths( int *argc, char **argv );
+/* fixaas.c */
+int FixAASMain( int argc, char **argv );
+
+
/* bsp.c */
int BSPMain( int argc, char **argv );
+/* bsp_analyze.c */
+int AnalyzeBSPMain( int argc, char **argv );
+
+
+/* bsp_info.c */
+int BSPInfoMain( int count, char **fileNames );
+
+/* bsp_scale.c */
+int ScaleBSPMain( int argc, char **argv );
+
+/* minimap.c */
+int MiniMapBSPMain( int argc, char **argv );
+
+/* convert_bsp.c */
+int ConvertBSPMain( int argc, char **argv );
+
+
/* convert_map.c */
int ConvertBSPToMap( char *bspName );
int ConvertBSPToMap_BP( char *bspName );
-
/* convert_ase.c */
int ConvertBSPToASE( char *bspName );
/* convert_obj.c */
int ConvertBSPToOBJ( char *bspName );
-
/* brush.c */
sideRef_t *AllocSideRef( side_t *side, sideRef_t *next );
int CountBrushList( brush_t *brushes );
/* leakfile.c */
-xmlNodePtr LeakFile( tree_t *tree );
+xmlNodePtr LeakFile( tree_t *tree, const char *lineFilePath );
/* prtfile.c */
void NumberClusters( tree_t *tree );
-void WritePortalFile( tree_t *tree );
+void WritePortalFile( tree_t *tree, const char *portalFilePath );
/* writebsp.c */
int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags );
void BeginBSPFile( void );
-void EndBSPFile( qboolean do_write );
+void EndBSPFile( qboolean do_write, const char *BSPFilePath, const char *surfaceFilePath );
void EmitBrushes( brush_t *brushes, int *firstBrush, int *numBrushes );
void EmitFogs( void );
float GetSurfaceExtraLongestCurve( int num );
void GetSurfaceExtraLightmapAxis( int num, vec3_t lightmapAxis );
-void WriteSurfaceExtraFile( const char *path );
-void LoadSurfaceExtraFile( const char *path );
+void WriteSurfaceExtraFile( const char *surfaceFilePath );
+void LoadSurfaceExtraFile( const char *surfaceFilePath );
/* decals.c */
void IlluminateRawLightmap( int num );
void IlluminateVertexes( int num );
-void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all );
+void SetupBrushesFlags( unsigned int mask_any, unsigned int test_any, unsigned int mask_all, unsigned int test_all );
void SetupBrushes( void );
void SetupClusters( void );
qboolean ClusterVisible( int a, int b );
void SetupSurfaceLightmaps( void );
void StitchSurfaceLightmaps( void );
-void StoreSurfaceLightmaps( void );
+void StoreSurfaceLightmaps( qboolean fastAllocate );
+
+
+/* exportents.c */
+void ExportEntities( void );
+int ExportEntitiesMain( int argc, char **argv );
/* image.c */
const char *ValueForKey( const entity_t *ent, const char *key );
int IntForKey( const entity_t *ent, const char *key );
vec_t FloatForKey( const entity_t *ent, const char *key );
-void GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec );
+qboolean GetVectorForKey( const entity_t *ent, const char *key, vec3_t vec );
entity_t *FindTargetEntity( const char *target );
void GetEntityShadowFlags( const entity_t *ent, const entity_t *ent2, int *castShadows, int *recvShadows );
void InjectCommandLine( char **argv, int beginArgs, int endArgs );
{
#include "game_quake3.h"
,
- #include "game_quakelive.h" /* most be after game_quake3.h as they share defines! */
+ #include "game_quakelive.h" /* must be after game_quake3.h as they share defines! */
,
- #include "game_nexuiz.h" /* most be after game_quake3.h as they share defines! */
+ #include "game_nexuiz.h" /* must be after game_quake3.h as they share defines! */
,
- #include "game_xonotic.h" /* most be after game_quake3.h as they share defines! */
+ #include "game_xonotic.h" /* must be after game_quake3.h as they share defines! */
,
#include "game_tremulous.h" /*LinuxManMikeC: must be after game_quake3.h, depends on #define's set in it */
+ ,
+ #include "game_unvanquished.h" /* must be after game_tremulous.h as they share defines! */
,
#include "game_tenebrae.h"
,
#include "game_wolf.h"
,
- #include "game_wolfet.h" /* most be after game_wolf.h as they share defines! */
+ #include "game_wolfet.h" /* must be after game_wolf.h as they share defines! */
,
#include "game_etut.h"
,
,
#include "game_sof2.h"
,
- #include "game_jk2.h" /* most be after game_sof2.h as they share defines! */
+ #include "game_jk2.h" /* must be after game_sof2.h as they share defines! */
,
- #include "game_ja.h" /* most be after game_jk2.h as they share defines! */
+ #include "game_ja.h" /* must be after game_jk2.h as they share defines! */
,
#include "game_qfusion.h" /* qfusion game */
,
Q_EXTERN qboolean doingBSP Q_ASSIGN( qfalse );
/* commandline arguments */
-Q_EXTERN qboolean nocmdline Q_ASSIGN( qfalse );
+Q_EXTERN qboolean nocmdline Q_ASSIGN( qfalse );
Q_EXTERN qboolean verbose;
Q_EXTERN qboolean verboseEntities Q_ASSIGN( qfalse );
Q_EXTERN qboolean force Q_ASSIGN( qfalse );
Q_EXTERN int sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE );
Q_EXTERN int minSampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE );
-Q_EXTERN float noVertexLighting Q_ASSIGN( 0.0f );
+Q_EXTERN qboolean noVertexLighting Q_ASSIGN( qfalse );
Q_EXTERN qboolean nolm Q_ASSIGN( qfalse );
Q_EXTERN qboolean noGridLighting Q_ASSIGN( qfalse );
Q_EXTERN qboolean debugCluster Q_ASSIGN( qfalse );
Q_EXTERN qboolean debugOrigin Q_ASSIGN( qfalse );
Q_EXTERN qboolean lightmapBorder Q_ASSIGN( qfalse );
+ //1=warn; 0=warn if lmsize>128
+ Q_EXTERN int debugSampleSize Q_ASSIGN( 0 );
/* longest distance across the map */
Q_EXTERN float maxMapDistance Q_ASSIGN( 0 );