6 #include "gtkutil/widget.h"
7 #include "stream/stringstream.h"
10 #include "preferences.h"
13 #include "gtkutil/accelerator.h"
14 #include "generic/callback.h"
17 int ToggleActions = 0;
21 gboolean ToggleActions0( ui::Widget widget, GdkEvent *event, gpointer user_data ){
24 //globalOutputStream() << "ToggleActions\n";
28 void SetCommonShader( const char* key, const char* shader ){
29 const char* gotShader = g_pGameDescription->getKeyValue( key );
30 UndoableCommand undo( "textureNameSetSelected" );
31 if ( gotShader && *gotShader ){
32 Select_SetShader( gotShader );
35 Select_SetShader( shader );
40 gboolean Areaportals_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
41 if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
42 if ( ButtonNum == 1 ){
49 if( ToggleActions == 0 ){
50 SetCommonShader( "shader_nodraw", "textures/common/nodraw" );
52 else if( ToggleActions == 1 ){
53 SetCommonShader( "shader_nodrawnonsolid", "textures/common/nodrawnonsolid" );
55 //SetCommonShader( "shader_caulk", "textures/common/caulk" );
56 //globalOutputStream() << "Found '" << "fullname" << "'\n";
64 gboolean Caulk_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
65 if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
66 SetCommonShader( "shader_caulk", "textures/common/caulk" );
74 gboolean Clip_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
75 if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
76 if ( ButtonNum == 3 ){
83 if( ToggleActions == 0 ){
84 SetCommonShader( "shader_clip", "textures/common/clip" );
86 else if( ToggleActions == 1 ){
87 SetCommonShader( "shader_weapclip", "textures/common/weapclip" );
96 gboolean Liquids_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
97 if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
98 if ( ButtonNum == 4 ){
105 if( ToggleActions == 0 ){
106 SetCommonShader( "shader_watercaulk", "textures/common/watercaulk" );
108 else if( ToggleActions == 1 ){
109 SetCommonShader( "shader_lavacaulk", "textures/common/lavacaulk" );
111 else if( ToggleActions == 2 ){
112 SetCommonShader( "shader_slimecaulk", "textures/common/slimecaulk" );
121 gboolean Hint_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
122 if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
123 if ( ButtonNum == 5 ){
130 if( ToggleActions == 0 ){
131 SetCommonShader( "shader_hint", "textures/common/hint" );
133 else if( ToggleActions == 1 ){
134 SetCommonShader( "shader_hintlocal", "textures/common/hintlocal" );
136 else if( ToggleActions == 2 ){
137 SetCommonShader( "shader_hintskip", "textures/common/hintskip" );
146 gboolean Trigger_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
147 if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
148 SetCommonShader( "shader_trigger", "textures/common/trigger" );
156 gboolean Detail_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
157 if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
158 GlobalCommands_find( "MakeDetail" ).m_callback();
166 gboolean Structural_button_press( ui::Widget widget, GdkEventButton *event, gpointer data ){
167 if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
168 GlobalCommands_find( "MakeStructural" ).m_callback();
176 ui::Toolbar create_filter_toolbar(){
177 auto filter_toolbar = ui::Toolbar::from( gtk_toolbar_new() );
178 gtk_orientable_set_orientation( GTK_ORIENTABLE(filter_toolbar), GTK_ORIENTATION_HORIZONTAL );
179 gtk_toolbar_set_style( filter_toolbar, GTK_TOOLBAR_ICONS );
180 filter_toolbar.show();
184 auto btn = ui::ToolItem::from(gtk_separator_tool_item_new());
186 filter_toolbar.add(btn);
189 g_signal_connect( G_OBJECT( filter_toolbar ), "enter_notify_event", G_CALLBACK( ToggleActions0 ), 0 );
191 toolbar_append_toggle_button( filter_toolbar, "World (ALT + 1)", "f-world.png", "FilterWorldBrushes" );
194 auto button = toolbar_append_toggle_button( filter_toolbar, "Structural (CTRL + SHIFT + D)\nRightClick: MakeStructural", "f-structural.png", "FilterStructural" );
195 g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Structural_button_press ), 0 );
199 auto button = toolbar_append_toggle_button( filter_toolbar, "Details (CTRL + D)\nRightClick: MakeDetail", "f-details.png", "FilterDetails" );
200 g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Detail_button_press ), 0 );
203 toolbar_append_toggle_button( filter_toolbar, "Patches (CTRL + P)", "patch_wireframe.png", "FilterPatches" );
207 auto button = toolbar_append_toggle_button( filter_toolbar, "Areaportals (ALT + 3)\nRightClick: toggle tex\n\tnoDraw\n\tnoDrawNonSolid", "f-areaportal.png", "FilterAreaportals" );
208 g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Areaportals_button_press ), 0 );
212 toolbar_append_toggle_button( filter_toolbar, "Translucent (ALT + 4)", "f-translucent.png", "FilterTranslucent" );
215 auto button = toolbar_append_toggle_button( filter_toolbar, "Liquids (ALT + 5)\nRightClick: toggle tex\n\twaterCaulk\n\tlavaCaulk\n\tslimeCaulk", "f-liquids.png", "FilterLiquids" );
216 g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Liquids_button_press ), 0 );
220 auto button = toolbar_append_toggle_button( filter_toolbar, "Caulk (ALT + 6)\nRightClick: tex Caulk", "f-caulk.png", "FilterCaulk" );
221 g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Caulk_button_press ), 0 );
225 auto button = toolbar_append_toggle_button( filter_toolbar, "Clips (ALT + 7)\nRightClick: toggle tex\n\tplayerClip\n\tweapClip", "f-clip.png", "FilterClips" );
226 g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Clip_button_press ), 0 );
230 auto button = toolbar_append_toggle_button( filter_toolbar, "HintsSkips (CTRL + H)\nRightClick: toggle tex\n\thint\n\thintLocal\n\thintSkip", "f-hint.png", "FilterHintsSkips" );
231 g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Hint_button_press ), 0 );
234 //toolbar_append_toggle_button( filter_toolbar, "Paths (ALT + 8)", "texture_lock.png", "FilterPaths" );
236 toolbar_append_toggle_button( filter_toolbar, "Entities (ALT + 2)", "f-entities.png", "FilterEntities" );
237 toolbar_append_toggle_button( filter_toolbar, "Lights (ALT + 0)", "f-lights.png", "FilterLights" );
238 toolbar_append_toggle_button( filter_toolbar, "Models (SHIFT + M)", "f-models.png", "FilterModels" );
241 auto button = toolbar_append_toggle_button( filter_toolbar, "Triggers (CTRL + SHIFT + T)\nRightClick: tex Trigger", "f-triggers.png", "FilterTriggers" );
242 g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Trigger_button_press ), 0 );
245 //toolbar_append_toggle_button( filter_toolbar, "Decals (SHIFT + D)", "f-decals.png", "FilterDecals" );
247 toolbar_append_button( filter_toolbar, "InvertFilters", "f-invert.png", "InvertFilters" );
248 toolbar_append_button( filter_toolbar, "ResetFilters", "f-reset.png", "ResetFilters" );
249 return filter_toolbar;