]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/filterbar.cpp
* added MeshTex plugin src to project (can't compile)
[xonotic/netradiant.git] / radiant / filterbar.cpp
1 #include "filterbar.h"
2 #include <gtk/gtktoolbar.h>
3 #include "gtkmisc.h"
4 #include "gtkutil/widget.h"
5 #include "stream/stringstream.h"
6 #include "select.h"
7 #include "iundo.h"
8 #include "preferences.h"
9
10 #include "commands.h"
11 #include "gtkutil/accelerator.h"
12 #include "generic/callback.h"
13
14
15
16
17 int ToggleActions = 0;
18 int ButtonNum = 0;
19
20 gboolean ToggleActions0( GtkWidget *widget, GdkEvent *event, gpointer user_data ){
21         ToggleActions = 0;
22         return FALSE;
23         //globalOutputStream() << "ToggleActions\n";
24 }
25
26 void SetCommonShader( const char* key, const char* shader ){
27         const char* gotShader = g_pGameDescription->getKeyValue( key );
28         UndoableCommand undo( "textureNameSetSelected" );
29         if ( gotShader && *gotShader ){
30                 Select_SetShader( gotShader );
31         }
32         else{
33                 Select_SetShader( shader );
34         }
35 }
36
37
38 gboolean Areaportals_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
39         if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
40                 if ( ButtonNum == 1 ){
41                         ToggleActions %= 2;
42                 }
43                 else{
44                         ToggleActions = 0;
45                         ButtonNum = 1;
46                 }
47                 if( ToggleActions == 0 ){
48                         SetCommonShader( "shader_nodraw", "textures/common/nodraw" );
49                 }
50                 else if( ToggleActions == 1 ){
51                         SetCommonShader( "shader_nodrawnonsolid", "textures/common/nodrawnonsolid" );
52                 }
53                 //SetCommonShader( "shader_caulk", "textures/common/caulk" );
54                 //globalOutputStream() << "Found '" << "fullname" << "'\n";
55                 ToggleActions++;
56                 return TRUE;
57         }
58         return FALSE;
59 }
60
61
62 gboolean Caulk_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
63         if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
64                 SetCommonShader( "shader_caulk", "textures/common/caulk" );
65                 ToggleActions = 0;
66                 return TRUE;
67         }
68         return FALSE;
69 }
70
71 gboolean Clip_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
72         if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
73                 if ( ButtonNum == 3 ){
74                         ToggleActions %= 2;
75                 }
76                 else{
77                         ToggleActions = 0;
78                         ButtonNum = 3;
79                 }
80                 if( ToggleActions == 0 ){
81                         SetCommonShader( "shader_clip", "textures/common/clip" );
82                 }
83                 else if( ToggleActions == 1 ){
84                         SetCommonShader( "shader_weapclip", "textures/common/weapclip" );
85                 }
86                 ToggleActions++;
87                 return TRUE;
88         }
89         return FALSE;
90 }
91
92 gboolean Liquids_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
93         if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
94                 if ( ButtonNum == 4 ){
95                         ToggleActions %= 3;
96                 }
97                 else{
98                         ToggleActions = 0;
99                         ButtonNum = 4;
100                 }
101                 if( ToggleActions == 0 ){
102                         SetCommonShader( "shader_watercaulk", "textures/common/watercaulk" );
103                 }
104                 else if( ToggleActions == 1 ){
105                         SetCommonShader( "shader_lavacaulk", "textures/common/lavacaulk" );
106                 }
107                 else if( ToggleActions == 2 ){
108                         SetCommonShader( "shader_slimecaulk", "textures/common/slimecaulk" );
109                 }
110                 ToggleActions++;
111                 return TRUE;
112         }
113         return FALSE;
114 }
115
116
117 gboolean Hint_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
118         if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
119                 if ( ButtonNum == 5 ){
120                         ToggleActions %= 3;
121                 }
122                 else{
123                         ToggleActions = 0;
124                         ButtonNum = 5;
125                 }
126                 if( ToggleActions == 0 ){
127                         SetCommonShader( "shader_hint", "textures/common/hint" );
128                 }
129                 else if( ToggleActions == 1 ){
130                         SetCommonShader( "shader_hintlocal", "textures/common/hintlocal" );
131                 }
132                 else if( ToggleActions == 2 ){
133                         SetCommonShader( "shader_hintskip", "textures/common/hintskip" );
134                 }
135                 ToggleActions++;
136                 return TRUE;
137         }
138         return FALSE;
139 }
140
141 gboolean Trigger_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
142         if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
143                 SetCommonShader( "shader_trigger", "textures/common/trigger" );
144                 ToggleActions = 0;
145                 return TRUE;
146         }
147         return FALSE;
148 }
149
150 gboolean Detail_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
151         if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
152                 GlobalCommands_find( "MakeDetail" ).m_callback();
153                 ToggleActions = 0;
154                 return TRUE;
155         }
156         return FALSE;
157 }
158
159 gboolean Structural_button_press( GtkWidget *widget, GdkEventButton *event, gpointer data ){
160         if ( event->button == 3 && event->type == GDK_BUTTON_PRESS ) {
161                 GlobalCommands_find( "MakeStructural" ).m_callback();
162                 ToggleActions = 0;
163                 return TRUE;
164         }
165         return FALSE;
166 }
167
168
169 GtkToolbar* create_filter_toolbar(){
170                         GtkToolbar* filter_toolbar = GTK_TOOLBAR( gtk_toolbar_new() );
171                         gtk_widget_show( GTK_WIDGET( filter_toolbar ) );
172                         g_signal_connect( G_OBJECT( filter_toolbar ), "enter_notify_event", G_CALLBACK( ToggleActions0 ), 0 );
173
174                         GtkToggleButton* button;
175
176                         toolbar_append_toggle_button( filter_toolbar, "World (ALT + 1)", "f-world.png", "FilterWorldBrushes" );
177
178                         button = toolbar_append_toggle_button( filter_toolbar, "Structural (CTRL + SHIFT + D)\nRightClick: MakeStructural", "f-structural.png", "FilterStructural" );
179                         g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Structural_button_press ), 0 );
180
181                         button = toolbar_append_toggle_button( filter_toolbar, "Details (CTRL + D)\nRightClick: MakeDetail", "f-details.png", "FilterDetails" );
182                         g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Detail_button_press ), 0 );
183
184
185                         toolbar_append_toggle_button( filter_toolbar, "Patches (CTRL + P)", "patch_wireframe.png", "FilterPatches" );
186                         gtk_toolbar_append_space( GTK_TOOLBAR( filter_toolbar ) );
187
188                         button = toolbar_append_toggle_button( filter_toolbar, "Areaportals (ALT + 3)\nRightClick: toggle tex\n\tnoDraw\n\tnoDrawNonSolid", "f-areaportal.png", "FilterAreaportals" );
189                         g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Areaportals_button_press ), 0 );
190
191
192
193                         toolbar_append_toggle_button( filter_toolbar, "Translucent (ALT + 4)", "f-translucent.png", "FilterTranslucent" );
194
195                         button = toolbar_append_toggle_button( filter_toolbar, "Liquids (ALT + 5)\nRightClick: toggle tex\n\twaterCaulk\n\tlavaCaulk\n\tslimeCaulk", "f-liquids.png", "FilterLiquids" );
196                         g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Liquids_button_press ), 0 );
197
198                         button = toolbar_append_toggle_button( filter_toolbar, "Caulk (ALT + 6)\nRightClick: tex Caulk", "f-caulk.png", "FilterCaulk" );
199                         g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Caulk_button_press ), 0 );
200
201                         button = toolbar_append_toggle_button( filter_toolbar, "Clips (ALT + 7)\nRightClick: toggle tex\n\tplayerClip\n\tweapClip", "f-clip.png", "FilterClips" );
202                         g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Clip_button_press ), 0 );
203
204                         button = toolbar_append_toggle_button( filter_toolbar, "HintsSkips (CTRL + H)\nRightClick: toggle tex\n\thint\n\thintLocal\n\thintSkip", "f-hint.png", "FilterHintsSkips" );
205                         g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Hint_button_press ), 0 );
206
207                         //toolbar_append_toggle_button( filter_toolbar, "Paths (ALT + 8)", "texture_lock.png", "FilterPaths" );
208                         gtk_toolbar_append_space( GTK_TOOLBAR( filter_toolbar ) );
209                         toolbar_append_toggle_button( filter_toolbar, "Entities (ALT + 2)", "f-entities.png", "FilterEntities" );
210                         toolbar_append_toggle_button( filter_toolbar, "Lights (ALT + 0)", "f-lights.png", "FilterLights" );
211                         toolbar_append_toggle_button( filter_toolbar, "Models (SHIFT + M)", "f-models.png", "FilterModels" );
212
213                         button = toolbar_append_toggle_button( filter_toolbar, "Triggers (CTRL + SHIFT + T)\nRightClick: tex Trigger", "f-triggers.png", "FilterTriggers" );
214                         g_signal_connect( G_OBJECT( button ), "button_press_event", G_CALLBACK( Trigger_button_press ), 0 );
215
216                         //toolbar_append_toggle_button( filter_toolbar, "Decals (SHIFT + D)", "f-decals.png", "FilterDecals" );
217                         gtk_toolbar_append_space( GTK_TOOLBAR( filter_toolbar ) );
218                         toolbar_append_button( filter_toolbar, "InvertFilters", "f-invert.png", "InvertFilters" );
219                         toolbar_append_button( filter_toolbar, "ResetFilters", "f-reset.png", "ResetFilters" );
220                         return filter_toolbar;
221 }