menus...
	* Shortcuts item moved from Help to Edit
misc...
	* fix: q1 mdl reader out of bounds reading crash
	* fix: q1 mdl loading of MDL_FRAME_GROUP case
	* fix: rightclick main wnd border, release in texbro glwidget == crash (unfreezepointer)
	* texbro: search in currently shown textures
	* ask for saving nonsaved map on project settings change
	* func_detail to nongame group ents counter
	* deiconify main wnd, unmaximize maximized view on app closing to save correct layout data
	* close preferences dialog on ESC
	* Enter = Ok in global and path settings dialogs
	* print renderer stats in XY views too
	* global 'show renderer stats' option, def = off
	* ~10x faster opengl text rendering
This commit is contained in:
Garux 2017-08-02 09:25:04 +03:00
parent cba5583d23
commit 65ca31fd44
12 changed files with 286 additions and 119 deletions

View File

@ -166,9 +166,14 @@ gboolean dialog_delete_callback( GtkWidget *widget, GdkEventAny* event, ModalDia
return TRUE; return TRUE;
} }
#include <gdk/gdkkeysyms.h>
GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, GtkWidget* contents ){ GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& dialog, GtkWidget* contents ){
GtkWindow* window = create_fixedsize_modal_dialog_window( 0, title, dialog ); GtkWindow* window = create_fixedsize_modal_dialog_window( 0, title, dialog );
GtkAccelGroup* accel = gtk_accel_group_new();
gtk_window_add_accel_group( window, accel );
GtkVBox* vbox1 = create_dialog_vbox( 8, 4 ); GtkVBox* vbox1 = create_dialog_vbox( 8, 4 );
gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox1 ) ); gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( vbox1 ) );
@ -180,6 +185,8 @@ GtkWindow* create_simple_modal_dialog_window( const char* title, ModalDialog& di
GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog );
gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( button ) ); gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( button ) );
gtk_widget_grab_default( GTK_WIDGET( button ) );
gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 );
return window; return window;
} }

View File

@ -169,7 +169,7 @@ GLFont *glfont_create( const char* font_string ){
return new GLFontCallList( font_list_base, font_ascent, font_descent, font_height ); return new GLFontCallList( font_list_base, font_ascent, font_descent, font_height );
} }
#else #elif 0
// new font code ripped from ZeroRadiant // new font code ripped from ZeroRadiant
@ -336,4 +336,68 @@ GLFont *glfont_create( const char* font_string ){
return new GLFontInternal( font_string ); return new GLFontInternal( font_string );
} }
#elif 1
#include <pango/pangoft2.h>
#include <pango/pango-utils.h>
#include <gtk/gtkglwidget.h>
GLFont *glfont_create( const char* font_string ){
GLuint font_list_base = glGenLists( 256 );
int font_height = 0, font_ascent = 0, font_descent = 0;
PangoFontDescription* font_desc = pango_font_description_from_string( font_string );
//PangoFontDescription* font_desc = pango_font_description_from_string( "arial 7" );
PangoFont* font = gdk_gl_font_use_pango_font( font_desc, 0, 256, font_list_base );
if ( font == 0 ) {
pango_font_description_free( font_desc );
font_desc = pango_font_description_from_string( "arial 8" );
font = gdk_gl_font_use_pango_font( font_desc, 0, 256, font_list_base );
}
if ( font == 0 ) {
pango_font_description_free( font_desc );
font_desc = pango_font_description_from_string( "fixed 8" );
font = gdk_gl_font_use_pango_font( font_desc, 0, 256, font_list_base );
}
if ( font == 0 ) {
pango_font_description_free( font_desc );
font_desc = pango_font_description_from_string( "courier new 8" );
font = gdk_gl_font_use_pango_font( font_desc, 0, 256, font_list_base );
}
if ( font != 0 ) {
PangoFontMap *fontmap = pango_ft2_font_map_new();
pango_ft2_font_map_set_resolution( PANGO_FT2_FONT_MAP( fontmap ), 72, 72 );
PangoContext *ft2_context = pango_font_map_create_context( fontmap );
pango_context_set_font_description( ft2_context, font_desc );
PangoLayout *layout = pango_layout_new( ft2_context );
#if 1 //FONT_SIZE_WORKAROUND
pango_layout_set_width( layout, -1 ); // -1 no wrapping. All text on one line.
pango_layout_set_text( layout, "_|The quick brown fox jumped over the lazy sleeping dog's back then sat on a tack.", -1 ); // -1 null-terminated string.
#endif
int font_ascent_pango_units = pango_layout_get_baseline( layout );
PangoRectangle log_rect;
pango_layout_get_extents( layout, NULL, &log_rect );
g_object_unref( G_OBJECT( layout ) );
int font_descent_pango_units = log_rect.height - font_ascent_pango_units;
pango_font_description_free( font_desc );
g_object_unref( G_OBJECT( ft2_context ) );
g_object_unref( G_OBJECT( fontmap ) );
font_ascent = PANGO_PIXELS_CEIL( font_ascent_pango_units );
font_descent = PANGO_PIXELS_CEIL( font_descent_pango_units );
font_height = font_ascent + font_descent;
}
return new GLFontCallList( font_list_base, font_ascent, font_descent, font_height );
}
#endif #endif

View File

@ -251,6 +251,23 @@ inline char* string_to_uppercase( char* string ){
return string; return string;
} }
//http://stackoverflow.com/questions/27303062/strstr-function-like-that-ignores-upper-or-lower-case
//chux: Somewhat tricky to match the corner cases of strstr() with inputs like "x","", "","x", "",""
inline const char* string_in_string_nocase( const char* haystack, const char* needle ) {
do {
const char* h = haystack;
const char* n = needle;
while ( std::tolower( ( unsigned char ) *h ) == std::tolower( ( unsigned char ) *n ) && *n ) {
h++;
n++;
}
if ( *n == 0 ) {
return haystack;
}
} while ( *haystack++ );
return 0;
}
/// \brief A re-entrant string tokeniser similar to strchr. /// \brief A re-entrant string tokeniser similar to strchr.
class StringTokeniser class StringTokeniser
{ {

View File

@ -158,14 +158,15 @@ void MDLSurface_read( Surface& surface, const byte* buffer, const char* name ){
break; break;
case MDL_FRAME_GROUP: case MDL_FRAME_GROUP:
int numframes = istream_read_int32_le( inputStream ); int numframes = istream_read_int32_le( inputStream );
inputStream.seek( ( MDL_XYZNORMAL_SIZE * 2 ) + ( numframes * 4 ) ); //inputStream.seek( ( MDL_XYZNORMAL_SIZE * 2 ) + ( numframes * 4 ) );
inputStream.seek( ( MDL_XYZNORMAL_SIZE * 4 ) + ( numframes * 4 ) + 16 );//group min_vec3 + max_vec3 + timings_float[numframes] + frame min_vec3 + max_vec3 + name_char[16]
found = true; found = true;
break; break;
} }
} }
} }
Array<mdlXyzNormal_t> mdlXyzNormals( header.numtris ); Array<mdlXyzNormal_t> mdlXyzNormals( header.numverts );
for ( Array<mdlXyzNormal_t>::iterator i = mdlXyzNormals.begin(); i != mdlXyzNormals.end(); ++i ) for ( Array<mdlXyzNormal_t>::iterator i = mdlXyzNormals.begin(); i != mdlXyzNormals.end(); ++i )
{ {
inputStream.read( ( *i ).v, 3 ); inputStream.read( ( *i ).v, 3 );

View File

@ -79,7 +79,6 @@ struct camwindow_globals_private_t
bool m_bCamInverseMouse; bool m_bCamInverseMouse;
bool m_bCamDiscrete; bool m_bCamDiscrete;
bool m_bCubicClipping; bool m_bCubicClipping;
bool m_showStats;
int m_nStrafeMode; int m_nStrafeMode;
camwindow_globals_private_t() : camwindow_globals_private_t() :
@ -89,7 +88,6 @@ struct camwindow_globals_private_t
m_bCamInverseMouse( false ), m_bCamInverseMouse( false ),
m_bCamDiscrete( true ), m_bCamDiscrete( true ),
m_bCubicClipping( false ), m_bCubicClipping( false ),
m_showStats( true ),
m_nStrafeMode( 3 ){ m_nStrafeMode( 3 ){
} }
@ -1559,10 +1557,10 @@ ShowStatsExportCaller g_show_stats_caller;
BoolExportCallback g_show_stats_callback( g_show_stats_caller ); BoolExportCallback g_show_stats_callback( g_show_stats_caller );
ToggleItem g_show_stats( g_show_stats_callback ); ToggleItem g_show_stats( g_show_stats_callback );
*/ */
BoolExportCaller g_show_stats_caller( g_camwindow_globals_private.m_showStats ); BoolExportCaller g_show_stats_caller( g_camwindow_globals.m_showStats );
ToggleItem g_show_stats( g_show_stats_caller ); ToggleItem g_show_stats( g_show_stats_caller );
void ShowStatsToggle(){ void ShowStatsToggle(){
g_camwindow_globals_private.m_showStats ^= 1; g_camwindow_globals.m_showStats ^= 1;
g_show_stats.update(); g_show_stats.update();
UpdateAllWindows(); UpdateAllWindows();
} }
@ -1709,7 +1707,7 @@ void CamWnd::Cam_Draw(){
glEnd(); glEnd();
} }
if ( g_camwindow_globals_private.m_showStats ) { if ( g_camwindow_globals.m_showStats ) {
glRasterPos3f( 1.0f, static_cast<float>( m_Camera.height ) - GlobalOpenGL().m_font->getPixelDescent(), 0.0f ); glRasterPos3f( 1.0f, static_cast<float>( m_Camera.height ) - GlobalOpenGL().m_font->getPixelDescent(), 0.0f );
extern const char* Renderer_GetStats(); extern const char* Renderer_GetStats();
GlobalOpenGL().drawString( Renderer_GetStats() ); GlobalOpenGL().drawString( Renderer_GetStats() );
@ -2142,7 +2140,7 @@ void CamWnd_Construct(){
GlobalToggles_insert( "ShowStats", FreeCaller<ShowStatsToggle>(), ToggleItem::AddCallbackCaller( g_show_stats ) ); GlobalToggles_insert( "ShowStats", FreeCaller<ShowStatsToggle>(), ToggleItem::AddCallbackCaller( g_show_stats ) );
GlobalPreferenceSystem().registerPreference( "ShowStats", BoolImportStringCaller( g_camwindow_globals_private.m_showStats ), BoolExportStringCaller( g_camwindow_globals_private.m_showStats ) ); GlobalPreferenceSystem().registerPreference( "ShowStats", BoolImportStringCaller( g_camwindow_globals.m_showStats ), BoolExportStringCaller( g_camwindow_globals.m_showStats ) );
GlobalPreferenceSystem().registerPreference( "MoveSpeed", IntImportStringCaller( g_camwindow_globals_private.m_nMoveSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_nMoveSpeed ) ); GlobalPreferenceSystem().registerPreference( "MoveSpeed", IntImportStringCaller( g_camwindow_globals_private.m_nMoveSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_nMoveSpeed ) );
GlobalPreferenceSystem().registerPreference( "CamLinkSpeed", BoolImportStringCaller( g_camwindow_globals_private.m_bCamLinkSpeed ), BoolExportStringCaller( g_camwindow_globals_private.m_bCamLinkSpeed ) ); GlobalPreferenceSystem().registerPreference( "CamLinkSpeed", BoolImportStringCaller( g_camwindow_globals_private.m_bCamLinkSpeed ), BoolExportStringCaller( g_camwindow_globals_private.m_bCamLinkSpeed ) );
GlobalPreferenceSystem().registerPreference( "AngleSpeed", IntImportStringCaller( g_camwindow_globals_private.m_nAngleSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_nAngleSpeed ) ); GlobalPreferenceSystem().registerPreference( "AngleSpeed", IntImportStringCaller( g_camwindow_globals_private.m_nAngleSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_nAngleSpeed ) );

View File

@ -72,11 +72,14 @@ struct camwindow_globals_t
bool m_bZoomInToPointer; bool m_bZoomInToPointer;
bool m_showStats;
camwindow_globals_t() : camwindow_globals_t() :
color_cameraback( 0.25f, 0.25f, 0.25f ), color_cameraback( 0.25f, 0.25f, 0.25f ),
color_selbrushes3d( 1.0f, 0.f, 0.f ), color_selbrushes3d( 1.0f, 0.f, 0.f ),
m_nCubicScale( 14 ), m_nCubicScale( 14 ),
m_bZoomInToPointer( true ){ m_bZoomInToPointer( true ),
m_showStats( false ){
} }
}; };

View File

@ -343,6 +343,7 @@ void ProjectSettingsDialog_ok( ProjectSettingsDialog& dialog ){
: dir; : dir;
if ( !path_equal( new_gamename, gamename_get() ) ) { if ( !path_equal( new_gamename, gamename_get() ) ) {
if ( ConfirmModified( "Edit Project Settings" ) ) {
ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Changing Game Name" ); ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Changing Game Name" );
EnginePath_Unrealise(); EnginePath_Unrealise();
@ -351,6 +352,7 @@ void ProjectSettingsDialog_ok( ProjectSettingsDialog& dialog ){
EnginePath_Realise(); EnginePath_Realise();
} }
}
if ( globalMappingMode().do_mapping_mode ) { if ( globalMappingMode().do_mapping_mode ) {
// read from gamemode_combo // read from gamemode_combo

View File

@ -1940,6 +1940,7 @@ GtkMenuItem* create_edit_menu(){
create_menu_item_with_mnemonic( menu, "Select Connected Entities", "SelectConnectedEntities" ); create_menu_item_with_mnemonic( menu, "Select Connected Entities", "SelectConnectedEntities" );
menu_separator( menu ); menu_separator( menu );
create_menu_item_with_mnemonic( menu, "Shortcuts...", FreeCaller<DoCommandListDlg>() );
create_menu_item_with_mnemonic( menu, "Pre_ferences...", "Preferences" ); create_menu_item_with_mnemonic( menu, "Pre_ferences...", "Preferences" );
return edit_menu_item; return edit_menu_item;
@ -2046,7 +2047,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){
create_check_menu_item_with_mnemonic( menu_in_menu, "Show Window Outline", "ShowWindowOutline" ); create_check_menu_item_with_mnemonic( menu_in_menu, "Show Window Outline", "ShowWindowOutline" );
create_check_menu_item_with_mnemonic( menu_in_menu, "Show Axes", "ShowAxes" ); create_check_menu_item_with_mnemonic( menu_in_menu, "Show Axes", "ShowAxes" );
create_check_menu_item_with_mnemonic( menu_in_menu, "Show Workzone", "ShowWorkzone" ); create_check_menu_item_with_mnemonic( menu_in_menu, "Show Workzone", "ShowWorkzone" );
create_check_menu_item_with_mnemonic( menu_in_menu, "Show Camera Stats", "ShowStats" ); create_check_menu_item_with_mnemonic( menu_in_menu, "Show Renderer Stats", "ShowStats" );
} }
{ {
@ -2256,7 +2257,6 @@ GtkMenuItem* create_help_menu(){
create_game_help_menu( menu ); create_game_help_menu( menu );
// create_menu_item_with_mnemonic( menu, "Bug report", FreeCaller<OpenBugReportURL>() ); // create_menu_item_with_mnemonic( menu, "Bug report", FreeCaller<OpenBugReportURL>() );
create_menu_item_with_mnemonic( menu, "Shortcuts", FreeCaller<DoCommandListDlg>() );
create_menu_item_with_mnemonic( menu, "_About", FreeCaller<DoAbout>() ); create_menu_item_with_mnemonic( menu, "_About", FreeCaller<DoAbout>() );
return help_menu_item; return help_menu_item;
@ -2768,6 +2768,98 @@ void MainFrame::OnSleep(){
} }
void MainFrame_toggleFullscreen(){
GtkWindow* wnd = MainFrame_getWindow();
if( gdk_window_get_state( GTK_WIDGET( wnd )->window ) & GDK_WINDOW_STATE_FULLSCREEN ){
//some portion of buttsex, because gtk_window_unfullscreen doesn't work correctly after calling some modal window
bool maximized = ( gdk_window_get_state( GTK_WIDGET( wnd )->window ) & GDK_WINDOW_STATE_MAXIMIZED );
gtk_window_unfullscreen( wnd );
if( maximized ){
gtk_window_unmaximize( wnd );
gtk_window_maximize( wnd );
}
else{
gtk_window_move( wnd, g_layout_globals.m_position.x, g_layout_globals.m_position.y );
gtk_window_resize( wnd, g_layout_globals.m_position.w, g_layout_globals.m_position.h );
}
}
else{
gtk_window_fullscreen( wnd );
}
}
class MaximizeView
{
public:
MaximizeView(): m_maximized( false ){
}
void toggle(){
return m_maximized ? restore() : maximize();
}
bool isMaximized(){
return m_maximized;
}
private:
bool m_maximized;
int m_vSplitPos;
int m_vSplit2Pos;
int m_hSplitPos;
void restore(){
m_maximized = false;
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), m_vSplitPos );
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), m_vSplit2Pos );
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), m_hSplitPos );
}
void maximize(){
m_maximized = true;
m_vSplitPos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_vSplit ) );
m_vSplit2Pos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_vSplit2 ) );
m_hSplitPos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_hSplit ) );
int vSplitX, vSplitY, vSplit2X, vSplit2Y, hSplitX, hSplitY;
gdk_window_get_origin( g_pParentWnd->m_vSplit->window, &vSplitX, &vSplitY );
gdk_window_get_origin( g_pParentWnd->m_vSplit2->window, &vSplit2X, &vSplit2Y );
gdk_window_get_origin( g_pParentWnd->m_hSplit->window, &hSplitX, &hSplitY );
vSplitY += m_vSplitPos;
vSplit2Y += m_vSplit2Pos;
hSplitX += m_hSplitPos;
int cur_x, cur_y;
Sys_GetCursorPos( MainFrame_getWindow(), &cur_x, &cur_y );
if( cur_x > hSplitX ){
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), 0 );
}
else{
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), 9999 );
}
if( cur_y > vSplitY ){
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), 0 );
}
else{
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), 9999 );
}
if( cur_y > vSplit2Y ){
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), 0 );
}
else{
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), 9999 );
}
}
};
MaximizeView g_maximizeview;
void Maximize_View(){
if( g_pParentWnd != 0 && g_pParentWnd->m_vSplit != 0 && g_pParentWnd->m_vSplit2 != 0 && g_pParentWnd->m_hSplit != 0 )
g_maximizeview.toggle();
}
GtkWindow* create_splash(){ GtkWindow* create_splash(){
GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) ); GtkWindow* window = GTK_WINDOW( gtk_window_new( GTK_WINDOW_TOPLEVEL ) );
gtk_window_set_decorated( window, FALSE ); gtk_window_set_decorated( window, FALSE );
@ -3143,6 +3235,14 @@ void MainFrame::Create(){
} }
void MainFrame::SaveWindowInfo(){ void MainFrame::SaveWindowInfo(){
//restore good state first
if( gdk_window_get_state( GTK_WIDGET( m_window )->window ) & GDK_WINDOW_STATE_ICONIFIED ){
gtk_window_deiconify( m_window );
}
if( g_maximizeview.isMaximized() ){
g_maximizeview.toggle();
}
if ( !FloatingGroupDialog() ) { if ( !FloatingGroupDialog() ) {
g_layout_globals.nXYHeight = gtk_paned_get_position( GTK_PANED( m_vSplit ) ); g_layout_globals.nXYHeight = gtk_paned_get_position( GTK_PANED( m_vSplit ) );
@ -3262,7 +3362,7 @@ void GlobalGL_sharedContextCreated(){
#ifdef WIN32 #ifdef WIN32
/* win32 is dodgy here, just use courier new then */ /* win32 is dodgy here, just use courier new then */
g_font = glfont_create( "arial 9" ); g_font = glfont_create( "arial 8" );
#else #else
GtkSettings *settings = gtk_settings_get_default(); GtkSettings *settings = gtk_settings_get_default();
gchar *fontname; gchar *fontname;
@ -3329,92 +3429,6 @@ void Layout_registerPreferencesPage(){
PreferencesDialog_addInterfacePage( FreeCaller1<PreferenceGroup&, Layout_constructPage>() ); PreferencesDialog_addInterfacePage( FreeCaller1<PreferenceGroup&, Layout_constructPage>() );
} }
void MainFrame_toggleFullscreen(){
GtkWindow* wnd = MainFrame_getWindow();
if( gdk_window_get_state( GTK_WIDGET( wnd )->window ) & GDK_WINDOW_STATE_FULLSCREEN ){
//some portion of buttsex, because gtk_window_unfullscreen doesn't work correctly after calling some modal window
bool maximize = ( gdk_window_get_state( GTK_WIDGET( wnd )->window ) & GDK_WINDOW_STATE_MAXIMIZED );
gtk_window_unfullscreen( wnd );
if( maximize ){
gtk_window_unmaximize( wnd );
gtk_window_maximize( wnd );
}
else{
gtk_window_move( wnd, g_layout_globals.m_position.x, g_layout_globals.m_position.y );
gtk_window_resize( wnd, g_layout_globals.m_position.w, g_layout_globals.m_position.h );
}
}
else{
gtk_window_fullscreen( wnd );
}
}
class MaximizeView
{
public:
MaximizeView(): m_maximized( false ){
}
void toggle(){
return m_maximized ? restore() : maximize();
}
private:
bool m_maximized;
int m_vSplitPos;
int m_vSplit2Pos;
int m_hSplitPos;
void restore(){
m_maximized = false;
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), m_vSplitPos );
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), m_vSplit2Pos );
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), m_hSplitPos );
}
void maximize(){
m_maximized = true;
m_vSplitPos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_vSplit ) );
m_vSplit2Pos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_vSplit2 ) );
m_hSplitPos = gtk_paned_get_position( GTK_PANED( g_pParentWnd->m_hSplit ) );
int vSplitX, vSplitY, vSplit2X, vSplit2Y, hSplitX, hSplitY;
gdk_window_get_origin( g_pParentWnd->m_vSplit->window, &vSplitX, &vSplitY );
gdk_window_get_origin( g_pParentWnd->m_vSplit2->window, &vSplit2X, &vSplit2Y );
gdk_window_get_origin( g_pParentWnd->m_hSplit->window, &hSplitX, &hSplitY );
vSplitY += m_vSplitPos;
vSplit2Y += m_vSplit2Pos;
hSplitX += m_hSplitPos;
int cur_x, cur_y;
Sys_GetCursorPos( MainFrame_getWindow(), &cur_x, &cur_y );
if( cur_x > hSplitX ){
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), 0 );
}
else{
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_hSplit ), 9999 );
}
if( cur_y > vSplitY ){
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), 0 );
}
else{
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit ), 9999 );
}
if( cur_y > vSplit2Y ){
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), 0 );
}
else{
gtk_paned_set_position( GTK_PANED( g_pParentWnd->m_vSplit2 ), 9999 );
}
}
};
MaximizeView g_maximizeview;
void Maximize_View(){
if( g_pParentWnd != 0 && g_pParentWnd->m_vSplit != 0 && g_pParentWnd->m_vSplit2 != 0 && g_pParentWnd->m_hSplit != 0 )
g_maximizeview.toggle();
}
void FocusAllViews(){ void FocusAllViews(){
XY_Centralize(); //using centralizing here, not focusing function XY_Centralize(); //using centralizing here, not focusing function

View File

@ -825,7 +825,8 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
if( entity->isContainer() ){ if( entity->isContainer() ){
++m_groupents; ++m_groupents;
if( !string_equal_nocase( "func_group", entity->getKeyValue( "classname" ) ) && if( !string_equal_nocase( "func_group", entity->getKeyValue( "classname" ) ) &&
!string_equal_nocase( "_decal", entity->getKeyValue( "classname" ) ) ){ !string_equal_nocase( "_decal", entity->getKeyValue( "classname" ) ) &&
!string_equal_nocase( "func_detail", entity->getKeyValue( "classname" ) ) ){
++m_groupents_ingame; ++m_groupents_ingame;
++m_ents_ingame; ++m_ents_ingame;
} }

View File

@ -692,12 +692,17 @@ PreferencesPage createPage( const char* treeName, const char* frameName ){
} }
}; };
#include <gdk/gdkkeysyms.h>
GtkWindow* PrefsDlg::BuildDialog(){ GtkWindow* PrefsDlg::BuildDialog(){
PreferencesDialog_addInterfacePreferences( FreeCaller1<PreferencesPage&, Interface_constructPreferences>() ); PreferencesDialog_addInterfacePreferences( FreeCaller1<PreferencesPage&, Interface_constructPreferences>() );
//Mouse_registerPreferencesPage(); //Mouse_registerPreferencesPage();
GtkWindow* dialog = create_floating_window( "NetRadiant Preferences", m_parent ); GtkWindow* dialog = create_floating_window( "NetRadiant Preferences", m_parent );
GtkAccelGroup* accel = gtk_accel_group_new();
gtk_window_add_accel_group( dialog, accel );
{ {
GtkWidget* mainvbox = gtk_vbox_new( FALSE, 5 ); GtkWidget* mainvbox = gtk_vbox_new( FALSE, 5 );
gtk_container_add( GTK_CONTAINER( dialog ), mainvbox ); gtk_container_add( GTK_CONTAINER( dialog ), mainvbox );
@ -716,6 +721,7 @@ GtkWindow* PrefsDlg::BuildDialog(){
{ {
GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &m_modal ); 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 ); gtk_box_pack_end( GTK_BOX( hbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 );
gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
} }
{ {
GtkButton* button = create_dialog_button( "Clean", G_CALLBACK( OnButtonClean ), this ); GtkButton* button = create_dialog_button( "Clean", G_CALLBACK( OnButtonClean ), this );

View File

@ -234,6 +234,7 @@ GtkWidget* m_scr_win_tags;
GtkWidget* m_tag_notebook; GtkWidget* m_tag_notebook;
GtkWidget* m_search_button; GtkWidget* m_search_button;
GtkWidget* m_shader_info_item; GtkWidget* m_shader_info_item;
GtkWidget* m_filter_entry;
std::set<CopiedString> m_all_tags; std::set<CopiedString> m_all_tags;
GtkListStore* m_all_tags_list; GtkListStore* m_all_tags_list;
@ -444,7 +445,7 @@ void Texture_NextPos( TextureBrowser& textureBrowser, TextureLayout& layout, qte
textureBrowser.getTextureWH( q, nWidth, nHeight ); textureBrowser.getTextureWH( q, nWidth, nHeight );
if ( layout.current_x + nWidth > textureBrowser.width - 8 && layout.current_row ) { // go to the next row unless the texture is the first on the row if ( layout.current_x + nWidth > textureBrowser.width - 8 && layout.current_row ) { // go to the next row unless the texture is the first on the row
layout.current_x = 8; layout.current_x = 8;
layout.current_y -= layout.current_row + TextureBrowser_fontHeight( textureBrowser ) + 4;//+4 layout.current_y -= layout.current_row + TextureBrowser_fontHeight( textureBrowser ) + 5;//+4
layout.current_row = 0; layout.current_row = 0;
} }
@ -476,11 +477,26 @@ bool TextureSearch_IsShown( const char* name ){
} }
} }
bool Texture_filtered( const char* name, TextureBrowser& textureBrowser ){
const char* filter = gtk_entry_get_text( GTK_ENTRY( textureBrowser.m_filter_entry ) );
if( string_empty( filter ) ){
return false;
}
if( string_in_string_nocase( name, filter ) != 0 ){
return false;
}
return true;
}
CopiedString g_notex; CopiedString g_notex;
CopiedString g_shadernotex; CopiedString g_shadernotex;
// if texture_showinuse jump over non in-use textures // if texture_showinuse jump over non in-use textures
bool Texture_IsShown( IShader* shader, bool show_shaders, bool show_textures, bool hideUnused, bool hideNonShadersInCommon ){ /*
bool show_shaders, bool show_textures, bool hideUnused, bool hideNonShadersInCommon
textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon
*/
bool Texture_IsShown( IShader* shader, TextureBrowser& textureBrowser ){
// filter notex / shadernotex images // filter notex / shadernotex images
if ( g_TextureBrowser_filterNotex && ( string_equal( g_notex.c_str(), shader->getTexture()->name ) || string_equal( g_shadernotex.c_str(), shader->getTexture()->name ) ) ) { if ( g_TextureBrowser_filterNotex && ( string_equal( g_notex.c_str(), shader->getTexture()->name ) || string_equal( g_shadernotex.c_str(), shader->getTexture()->name ) ) ) {
return false; return false;
@ -503,19 +519,19 @@ bool Texture_IsShown( IShader* shader, bool show_shaders, bool show_textures, bo
return false; return false;
} }
if ( !show_shaders && !shader->IsDefault() ) { if ( !textureBrowser.m_showShaders && !shader->IsDefault() ) {
return false; return false;
} }
if ( !show_textures && shader->IsDefault() ) { if ( !textureBrowser.m_showTextures && shader->IsDefault() ) {
return false; return false;
} }
if ( hideUnused && !shader->IsInUse() ) { if ( textureBrowser.m_hideUnused && !shader->IsInUse() ) {
return false; return false;
} }
if( hideNonShadersInCommon && shader->IsDefault() && !shader->IsInUse() //&& g_TextureBrowser_currentDirectory != "" if( textureBrowser.m_hideNonShadersInCommon && shader->IsDefault() && !shader->IsInUse() //&& g_TextureBrowser_currentDirectory != ""
&& shader_equal_prefix( shader_get_textureName( shader->getName() ), TextureBrowser_getComonShadersDir() ) ){ && shader_equal_prefix( shader_get_textureName( shader->getName() ), TextureBrowser_getComonShadersDir() ) ){
return false; return false;
} }
@ -534,6 +550,10 @@ bool Texture_IsShown( IShader* shader, bool show_shaders, bool show_textures, bo
} }
} }
if( Texture_filtered( path_get_filename_start( shader->getName() ), textureBrowser ) ){
return false;
}
return true; return true;
} }
@ -556,7 +576,7 @@ void TextureBrowser_evaluateHeight( TextureBrowser& textureBrowser ){
{ {
IShader* shader = QERApp_ActiveShaders_IteratorCurrent(); IShader* shader = QERApp_ActiveShaders_IteratorCurrent();
if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon ) ) { if ( !Texture_IsShown( shader, textureBrowser ) ) {
continue; continue;
} }
@ -908,7 +928,7 @@ void TextureBrowser_Focus( TextureBrowser& textureBrowser, const char* name ){
{ {
IShader* shader = QERApp_ActiveShaders_IteratorCurrent(); IShader* shader = QERApp_ActiveShaders_IteratorCurrent();
if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon ) ) { if ( !Texture_IsShown( shader, textureBrowser ) ) {
continue; continue;
} }
@ -952,7 +972,7 @@ IShader* Texture_At( TextureBrowser& textureBrowser, int mx, int my ){
{ {
IShader* shader = QERApp_ActiveShaders_IteratorCurrent(); IShader* shader = QERApp_ActiveShaders_IteratorCurrent();
if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon ) ) { if ( !Texture_IsShown( shader, textureBrowser ) ) {
continue; continue;
} }
@ -1019,8 +1039,10 @@ void TextureBrowser_trackingDelta( int x, int y, unsigned int state, void* data
} }
void TextureBrowser_Tracking_MouseUp( TextureBrowser& textureBrowser ){ void TextureBrowser_Tracking_MouseUp( TextureBrowser& textureBrowser ){
if( textureBrowser.m_move_started ){
textureBrowser.m_move_started = false; textureBrowser.m_move_started = false;
textureBrowser.m_freezePointer.unfreeze_pointer( textureBrowser.m_parent, false ); textureBrowser.m_freezePointer.unfreeze_pointer( textureBrowser.m_parent, false );
}
} }
void TextureBrowser_Tracking_MouseDown( TextureBrowser& textureBrowser ){ void TextureBrowser_Tracking_MouseDown( TextureBrowser& textureBrowser ){
@ -1100,7 +1122,7 @@ void Texture_Draw( TextureBrowser& textureBrowser ){
{ {
IShader* shader = QERApp_ActiveShaders_IteratorCurrent(); IShader* shader = QERApp_ActiveShaders_IteratorCurrent();
if ( !Texture_IsShown( shader, textureBrowser.m_showShaders, textureBrowser.m_showTextures, textureBrowser.m_hideUnused, textureBrowser.m_hideNonShadersInCommon ) ) { if ( !Texture_IsShown( shader, textureBrowser ) ) {
continue; continue;
} }
@ -1242,7 +1264,7 @@ void Texture_Draw( TextureBrowser& textureBrowser ){
glDisable( GL_TEXTURE_2D ); glDisable( GL_TEXTURE_2D );
glColor3f( 1,1,1 ); glColor3f( 1,1,1 );
glRasterPos2i( x, y - TextureBrowser_fontHeight( textureBrowser ) + 2 );//+5 glRasterPos2i( x, y - TextureBrowser_fontHeight( textureBrowser ) + 3 );//+5
// don't draw the directory name // don't draw the directory name
const char* name = shader->getName(); const char* name = shader->getName();
@ -1676,6 +1698,7 @@ void TextureBrowser_createTreeViewTree(){
g_signal_connect( g_TextureBrowser.m_treeViewTree, "row-activated", (GCallback) TreeView_onRowActivated, NULL ); g_signal_connect( g_TextureBrowser.m_treeViewTree, "row-activated", (GCallback) TreeView_onRowActivated, NULL );
renderer = gtk_cell_renderer_text_new(); renderer = gtk_cell_renderer_text_new();
//g_object_set( G_OBJECT( renderer ), "ellipsize", PANGO_ELLIPSIZE_START, NULL );
gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), -1, "", renderer, "text", 0, NULL ); gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( g_TextureBrowser.m_treeViewTree ), -1, "", renderer, "text", 0, NULL );
TextureBrowser_constructTreeStore(); TextureBrowser_constructTreeStore();
@ -2087,6 +2110,11 @@ void TextureBrowser_SetNotex(){
g_shadernotex = name.c_str(); g_shadernotex = name.c_str();
} }
void TextureBrowser_filterChanged( GtkEditable *editable, TextureBrowser* textureBrowser ){
TextureBrowser_heightChanged( *textureBrowser );
textureBrowser->m_originInvalid = true;
}
GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){
// The gl_widget and the tag assignment frame should be packed into a GtkVPaned with the slider // The gl_widget and the tag assignment frame should be packed into a GtkVPaned with the slider
// position stored in local.pref. gtk_paned_get_position() and gtk_paned_set_position() don't // position stored in local.pref. gtk_paned_get_position() and gtk_paned_set_position() don't
@ -2154,6 +2182,13 @@ GtkWidget* TextureBrowser_constructWindow( GtkWindow* toplevel ){
//gtk_table_attach( GTK_TABLE( table ), menu_bar, 0, 3, 0, 1, GTK_FILL, GTK_SHRINK, 0, 0 ); //gtk_table_attach( GTK_TABLE( table ), menu_bar, 0, 3, 0, 1, GTK_FILL, GTK_SHRINK, 0, 0 );
//gtk_widget_show( menu_bar ); //gtk_widget_show( menu_bar );
} }
{//filter entry
GtkWidget* entry = gtk_entry_new();
gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( entry ), FALSE, FALSE, 0 );
gtk_widget_show( entry );
g_TextureBrowser.m_filter_entry = entry;
g_signal_connect( G_OBJECT( entry ), "changed", G_CALLBACK( TextureBrowser_filterChanged ), &g_TextureBrowser );
}
{ // Texture TreeView { // Texture TreeView
g_TextureBrowser.m_scr_win_tree = gtk_scrolled_window_new( NULL, NULL ); g_TextureBrowser.m_scr_win_tree = gtk_scrolled_window_new( NULL, NULL );
gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tree ), 0 ); gtk_container_set_border_width( GTK_CONTAINER( g_TextureBrowser.m_scr_win_tree ), 0 );

View File

@ -138,8 +138,8 @@ void ClipPoint::Draw( const char *label, float scale ){
// draw label // draw label
glRasterPos3f( m_ptClip[0] + offset, m_ptClip[1] + offset, m_ptClip[2] + offset ); glRasterPos3f( m_ptClip[0] + offset, m_ptClip[1] + offset, m_ptClip[2] + offset );
//glCallLists( GLsizei( strlen( label ) ), GL_UNSIGNED_BYTE, label ); //fails with GCC //glCallLists( GLsizei( strlen( label ) ), GL_UNSIGNED_BYTE, label ); //fails //new font rendering?
//glCallLists( GLsizei( strlen( label ) ), GL_UNSIGNED_BYTE, reinterpret_cast<const GLubyte*>( label ) ); //worx //glCallLists( GLsizei( strlen( label ) ), GL_UNSIGNED_BYTE, reinterpret_cast<const GLubyte*>( label ) ); //worx :o
GlobalOpenGL().drawString( label ); GlobalOpenGL().drawString( label );
} }
@ -2594,6 +2594,9 @@ void XYWnd::XY_Draw(){
glClear( GL_COLOR_BUFFER_BIT ); glClear( GL_COLOR_BUFFER_BIT );
extern void Renderer_ResetStats();
Renderer_ResetStats();
// //
// set up viewpoint // set up viewpoint
// //
@ -2763,6 +2766,22 @@ void XYWnd::XY_Draw(){
} }
} }
if( g_camwindow_globals.m_showStats ){
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho( 0, m_nWidth, 0, m_nHeight, 0, 1 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glColor3fv( vector3_to_array( g_xywindow_globals.color_viewname ) );
glRasterPos3f( 2.f, GlobalOpenGL().m_font->getPixelDescent() + 1.f, 0.0f );
extern const char* Renderer_GetStats();
GlobalOpenGL().drawString( Renderer_GetStats() );
}
GlobalOpenGL_debugAssertNoErrors(); GlobalOpenGL_debugAssertNoErrors();
glFinish(); glFinish();