From 9aa5e96c6320c921a7b1ec69c6315a76a36e228a Mon Sep 17 00:00:00 2001 From: rambetter Date: Sun, 23 Jan 2011 05:24:30 +0000 Subject: [PATCH] Adding "Preferences" -> "Other" -> "Brush" tab. This now has "Default texture scale:". (Preferences are game specific by the way.) The default value for this preference is specific to a game, but most of the time it's 0.5. This field allows the user to override that default. This is a feature that was specifically requrested by someone who wants to try using ZeroRadiant (he wants to set it to 0.25 for his "premium" maps). It's already a feature in NetRadiant. git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@436 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- radiant/brush.cpp | 8 +++---- radiant/pmesh.cpp | 16 ++++++------- radiant/preferences.cpp | 51 +++++++++++++++++++++++++++++++++++++++++ radiant/preferences.h | 3 ++- radiant/texwindow.cpp | 8 +++---- 5 files changed, 69 insertions(+), 17 deletions(-) diff --git a/radiant/brush.cpp b/radiant/brush.cpp index 59daecb6..880fac67 100644 --- a/radiant/brush.cpp +++ b/radiant/brush.cpp @@ -309,9 +309,9 @@ void Face_MoveTexture(face_t *f, vec3_t delta) vShift[1] = vDP[0] * s + vDP[1] * c; if (!f->texdef.scale[0]) - f->texdef.scale[0] = g_pGameDescription->mTextureDefaultScale; + f->texdef.scale[0] = g_PrefsDlg.m_fDefTextureScale; if (!f->texdef.scale[1]) - f->texdef.scale[1] = g_pGameDescription->mTextureDefaultScale; + f->texdef.scale[1] = g_PrefsDlg.m_fDefTextureScale; f->texdef.shift[0] -= vShift[0] / f->texdef.scale[0]; f->texdef.shift[1] -= vShift[1] / f->texdef.scale[1]; @@ -364,9 +364,9 @@ void Face_TextureVectors (face_t *f, float STfromXYZ[2][4]) memset (STfromXYZ, 0, 8*sizeof(float)); if (!td->scale[0]) - td->scale[0] = g_pGameDescription->mTextureDefaultScale; + td->scale[0] = g_PrefsDlg.m_fDefTextureScale; if (!td->scale[1]) - td->scale[1] = g_pGameDescription->mTextureDefaultScale; + td->scale[1] = g_PrefsDlg.m_fDefTextureScale; // get natural texture axis TextureAxisFromPlane(&f->plane, pvecs[0], pvecs[1]); diff --git a/radiant/pmesh.cpp b/radiant/pmesh.cpp index dea9ef0a..15c2bff9 100644 --- a/radiant/pmesh.cpp +++ b/radiant/pmesh.cpp @@ -694,8 +694,8 @@ dist( this control point to first control point ) / dist ( last control pt to fi */ void WINAPI Patch_Naturalize(patchMesh_t *p) { - int nWidth = (int)(p->d_texture->width * g_pGameDescription->mTextureDefaultScale); - int nHeight = (int)(p->d_texture->height * g_pGameDescription->mTextureDefaultScale); + int nWidth = (int)(p->d_texture->width * g_PrefsDlg.m_fDefTextureScale); + int nHeight = (int)(p->d_texture->height * g_PrefsDlg.m_fDefTextureScale); float fPWidth = Patch_Width(p); float fPHeight = Patch_Height(p); float xAccum = 0.0f; @@ -865,18 +865,18 @@ void Patch_CapTexture(patchMesh_t *p, bool bFaceCycle = false) { if (vProjection[2] == 1.0f || (vX[0] == 1.0f && vY[1] == -1.0f)) { - p->ctrl[w][h].st[0] = p->ctrl[w][h].xyz[0] / (texture->width * g_pGameDescription->mTextureDefaultScale); - p->ctrl[w][h].st[1] = p->ctrl[w][h].xyz[1] / (texture->height * g_pGameDescription->mTextureDefaultScale) * -1; + p->ctrl[w][h].st[0] = p->ctrl[w][h].xyz[0] / (texture->width * g_PrefsDlg.m_fDefTextureScale); + p->ctrl[w][h].st[1] = p->ctrl[w][h].xyz[1] / (texture->height * g_PrefsDlg.m_fDefTextureScale) * -1; } else if (vProjection[0] == 1.0f || (vX[1] == 1.0f && vY[2] == -1.0f)) { - p->ctrl[w][h].st[0] = p->ctrl[w][h].xyz[1] / (texture->width * g_pGameDescription->mTextureDefaultScale); - p->ctrl[w][h].st[1] = p->ctrl[w][h].xyz[2] / (texture->height * g_pGameDescription->mTextureDefaultScale) * -1; + p->ctrl[w][h].st[0] = p->ctrl[w][h].xyz[1] / (texture->width * g_PrefsDlg.m_fDefTextureScale); + p->ctrl[w][h].st[1] = p->ctrl[w][h].xyz[2] / (texture->height * g_PrefsDlg.m_fDefTextureScale) * -1; } else if (vProjection[1] == 1.0f || (vX[0] == 1.0f && vY[2] == -1.0f)) { - p->ctrl[w][h].st[0] = p->ctrl[w][h].xyz[0] / (texture->width * g_pGameDescription->mTextureDefaultScale); - p->ctrl[w][h].st[1] = p->ctrl[w][h].xyz[2] / (texture->height * g_pGameDescription->mTextureDefaultScale) * -1; + p->ctrl[w][h].st[0] = p->ctrl[w][h].xyz[0] / (texture->width * g_PrefsDlg.m_fDefTextureScale); + p->ctrl[w][h].st[1] = p->ctrl[w][h].xyz[2] / (texture->height * g_PrefsDlg.m_fDefTextureScale) * -1; } //Sys_Printf("(%i,%i) (%f,%f,%f) (%f,%f) %f\n",w,h, // p->ctrl[w][h].xyz[0],p->ctrl[w][h].xyz[1],p->ctrl[w][h].xyz[2], diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index cc31a540..44f8bfbf 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -137,6 +137,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define LEAKSTOP_KEY "LeakStop" #define DOSLEEP_KEY "SleepMode" #define SUBDIVISIONS_KEY "Subdivisions" +#define DEFAULTTEXURESCALE_KEY "DefaultTextureScale" #define CLIPCAULK_KEY "ClipCaulk" #define PATCHSHOWBOUNDS_KEY "PatchShowBounds" #define NATIVEGUI_KEY "NativeGUI" @@ -1727,6 +1728,11 @@ void PrefsDlg::BuildDialog () gtk_tree_store_append(store, &tab, &group); gtk_tree_store_set(store, &tab, 0, _("Paths"), 1, (gpointer)PTAB_PATHS, -1); } + { + GtkTreeIter tab; + gtk_tree_store_append(store, &tab, &group); + gtk_tree_store_set(store, &tab, 0, _("Brush"), 1, (gpointer)PTAB_BRUSH, -1); + } { GtkTreeIter tab; gtk_tree_store_append(store, &tab, &group); @@ -2549,6 +2555,47 @@ void PrefsDlg::BuildDialog () // Add the page to the notebook gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel); + /******** Brush group ********/ + preflabel = gtk_label_new(_("Brush")); + gtk_widget_show(preflabel); + pageframe = gtk_frame_new(_("Brush")); + gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5); + gtk_widget_show(pageframe); + vbox = gtk_vbox_new(FALSE, 5); + gtk_widget_show(vbox); + gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); + gtk_container_add(GTK_CONTAINER(pageframe), vbox); + + // default texture scale + // table + table = gtk_table_new(2, 1, FALSE); // I believe that the 2 and 1 are switched here, and this is + // intentional to be consistent with other calls to gtk_table_new() + // [that are probably also switched]. + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, TRUE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), 5); + gtk_table_set_col_spacings(GTK_TABLE(table), 5); + + // label + label = gtk_label_new(_("Default texture scale:")); + gtk_widget_show(label); + gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); + gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, + (GtkAttachOptions) (0), + (GtkAttachOptions) (0), 0, 0); + + // scale entry + entry = gtk_entry_new(); + gtk_widget_show(entry); + gtk_widget_set_usize(GTK_WIDGET(entry), 60, -2); + gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 0, 1, + (GtkAttachOptions) (GTK_FILL), + (GtkAttachOptions) (0), 0, 0); + AddDialogData(entry, &m_fDefTextureScale, DLG_ENTRY_FLOAT); + + // Add the page to the notebook + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel); + /******** Misc group *********/ preflabel = gtk_label_new(_("Misc")); gtk_widget_show(preflabel); @@ -2970,6 +3017,7 @@ void PrefsDlg::LoadPrefs () mLocalPrefs.GetPref(SELECTCURVES_KEY, &m_bSelectCurves, TRUE); mLocalPrefs.GetPref(SELECTMODELS_KEY, &m_bSelectModels, TRUE); mLocalPrefs.GetPref(SHADERLISTONLY_KEY, &m_bTexturesShaderlistOnly, FALSE); + mLocalPrefs.GetPref(DEFAULTTEXURESCALE_KEY, &m_fDefTextureScale, g_pGameDescription->mTextureDefaultScale); mLocalPrefs.GetPref(SUBDIVISIONS_KEY, &m_nSubdivisions, SUBDIVISIONS_DEF); mLocalPrefs.GetPref(CLIPCAULK_KEY, &m_bClipCaulk, FALSE); mLocalPrefs.GetPref(SNAPTTOGRID_KEY, &m_bSnapTToGrid, FALSE); @@ -3511,6 +3559,9 @@ void CGameInstall::Run() { Str dest = m_strEngine.GetBuffer(); CopyTree( source.GetBuffer(), dest.GetBuffer() ); fprintf( fg, " basegame=\"Boomstick\"\n" ); + fprintf( fg, " default_scale=\"0.5\"\n" ); // Superfluous because the default is already 0.5, + // but demonstrates how to set the default texture scale + // for a specific game. break; } } diff --git a/radiant/preferences.h b/radiant/preferences.h index 49c69725..1b2e0469 100644 --- a/radiant/preferences.h +++ b/radiant/preferences.h @@ -475,7 +475,7 @@ public: // Gef: updated preferences dialog /*! Preference notebook page numbers */ enum {PTAB_FRONT = 0, PTAB_GAME_SETTINGS, PTAB_2D, PTAB_CAMERA, PTAB_TEXTURE, PTAB_LAYOUT, PTAB_MOUSE, - PTAB_EDITING, PTAB_STARTUP, PTAB_PATHS, PTAB_MISC, PTAB_BSPMONITOR} pref_tabs; + PTAB_EDITING, PTAB_STARTUP, PTAB_PATHS, PTAB_BRUSH, PTAB_MISC, PTAB_BSPMONITOR} pref_tabs; GtkWidget *notebook; @@ -613,6 +613,7 @@ public: bool m_bGLLighting; bool m_bTexturesShaderlistOnly; int m_nSubdivisions; + float m_fDefTextureScale; bool m_bFloatingZ; bool m_bLatchedFloatingZ; // Gef: Kyro GL_POINT workaround diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 9e30e2d2..d52ddb7c 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -1330,8 +1330,8 @@ void SelectTexture (int mx, int my, bool bShift, bool bFitScale) } else { - tex.scale[0] = g_pGameDescription->mTextureDefaultScale; - tex.scale[1] = g_pGameDescription->mTextureDefaultScale; + tex.scale[0] = g_PrefsDlg.m_fDefTextureScale; + tex.scale[1] = g_PrefsDlg.m_fDefTextureScale; } tex.flags = pCurrentShader->getFlags(); // TTimo - shader code cleanup @@ -1935,8 +1935,8 @@ void TexWnd::DragDropTexture (guint32 flags, int pointx, int pointy) brushprimit_tex.coords[1][1] = 1.0f; } else { - tex.scale[0] = g_pGameDescription->mTextureDefaultScale; - tex.scale[1] = g_pGameDescription->mTextureDefaultScale; + tex.scale[0] = g_PrefsDlg.m_fDefTextureScale; + tex.scale[1] = g_PrefsDlg.m_fDefTextureScale; } tex.flags = g_qeglobals.d_texturewin.texdef.flags; tex.value = g_qeglobals.d_texturewin.texdef.value; -- 2.39.2