From a0d8a59d58233477abf11f01027ef71334251cd2 Mon Sep 17 00:00:00 2001 From: SanyaSho Date: Tue, 16 Aug 2022 16:58:40 +0300 Subject: [PATCH] game: touch customization and small update --- game/client/touch.cpp | 28 +++++++++++++++++++++++++--- game/client/touch.h | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/game/client/touch.cpp b/game/client/touch.cpp index c695b975..a6df7dcb 100644 --- a/game/client/touch.cpp +++ b/game/client/touch.cpp @@ -17,6 +17,8 @@ extern ConVar cl_forwardspeed; extern ConVar cl_upspeed; extern ConVar default_fov; +extern IMatSystemSurface *g_pMatSystemSurface; + #ifdef ANDROID #define TOUCH_DEFAULT "1" #else @@ -232,6 +234,15 @@ CON_COMMAND( touch_loaddefaults, "generate config from defaults" ) { gTouch.ResetToDefaults(); } + +CON_COMMAND( touch_setgridcolor, "change grid color" ) +{ + if( args.ArgC() >= 5 ) + gTouch.gridcolor = rgba_t( Q_atoi( args[1] ), Q_atoi( args[2] ), Q_atoi( args[3] ), Q_atoi( args[4] ) ); + else + Msg( "Usage: touch_setgridcolor \n" ); +} + /* CON_COMMAND( touch_roundall, "round all buttons coordinates to grid" ) { @@ -294,6 +305,7 @@ void CTouchControls::ResetToDefaults() { rgba_t color(255, 255, 255, 155); char buf[MAX_PATH]; + gridcolor = rgba_t(255, 0, 0, 50); RemoveButtons(); @@ -351,6 +363,7 @@ void CTouchControls::Init() mouse_events = 0; move_start_x = move_start_y = 0.0f; m_flPreviousYaw = m_flPreviousPitch = 0.f; + gridcolor = rgba_t(255, 0, 0, 50); showtexture = hidetexture = resettexture = closetexture = joytexture = 0; configchanged = false; @@ -463,7 +476,7 @@ void CTouchControls::Paint( ) if( state == state_edit ) { - vgui::surface()->DrawSetColor(255, 0, 0, 200); + vgui::surface()->DrawSetColor(gridcolor.r, gridcolor.g, gridcolor.b, gridcolor.a*3); // 255, 0, 0, 200 <- default here float x,y; for( x = 0.0f; x < 1.0f; x += GRID_X ) @@ -471,6 +484,7 @@ void CTouchControls::Paint( ) for( y = 0.0f; y < 1.0f; y += GRID_Y ) vgui::surface()->DrawLine( 0, screen_h*y, screen_w, screen_h*y ); + } CUtlLinkedList::iterator it; @@ -487,7 +501,13 @@ void CTouchControls::Paint( ) if( state == state_edit && !(btn->flags & TOUCH_FL_NOEDIT) ) { - vgui::surface()->DrawSetColor(255, 0, 0, 50); + g_pMatSystemSurface->DrawColoredText( 2, btn->x1*screen_w, btn->y1*screen_h, 255, 255, 255, 255, "N: %s", btn->name ); // name + g_pMatSystemSurface->DrawColoredText( 2, btn->x1*screen_w, btn->y1*screen_h+10, 255, 255, 255, 255, "T: %s", btn->texturefile ); // texture + g_pMatSystemSurface->DrawColoredText( 2, btn->x1*screen_w, btn->y1*screen_h+20, 255, 255, 255, 255, "C: %s", btn->command ); // command + g_pMatSystemSurface->DrawColoredText( 2, btn->x1*screen_w, btn->y1*screen_h+30, 255, 255, 255, 255, "F: %i", btn->flags ); // flags + g_pMatSystemSurface->DrawColoredText( 2, btn->x1*screen_w, btn->y1*screen_h+40, 255, 255, 255, 255, "RGBA: %d %d %d %d", btn->color.r, btn->color.g, btn->color.b, btn->color.a );// color + + vgui::surface()->DrawSetColor(gridcolor.r, gridcolor.g, gridcolor.b, gridcolor.a); // 255, 0, 0, 50 <- default here vgui::surface()->DrawFilledRect( btn->x1*screen_w, btn->y1*screen_h, btn->x2*screen_w, btn->y2*screen_h ); } } @@ -795,7 +815,7 @@ void CTouchControls::EnableTouchEdit(bool enable) resize_finger = move_finger = look_finger = wheel_finger = -1; move_button = NULL; configchanged = true; - AddButton( "close_edit", "vgui/touch/back", "touch_disableedit", 0.010000, 0.837778, 0.080000, 0.980000, rgba_t(255,255,255,255), 0, 1.f, TOUCH_FL_NOEDIT ); + AddButton( "close_edit", "vgui/touch/back", "touch_disableedit", 0.020000, 0.800000, 0.100000, 0.977778, rgba_t(255,255,255,255), 0, 1.f, TOUCH_FL_NOEDIT ); } else { @@ -848,6 +868,8 @@ void CTouchControls::WriteConfig() filesystem->FPrintf( f, "\n// grid settings\n" ); filesystem->FPrintf( f, "touch_grid_count \"%d\"\n", touch_grid_count.GetInt() ); filesystem->FPrintf( f, "touch_grid_enable \"%d\"\n", touch_grid_enable.GetInt() ); + + filesystem->FPrintf( f, "touch_setgridcolor \"%d\" \"%d\" \"%d\" \"%d\"\n", gridcolor.r, gridcolor.g, gridcolor.b, gridcolor.a ); /* filesystem->FPrintf( f, "\n// global overstroke (width, r, g, b, a)\n" ); filesystem->FPrintf( f, "touch_set_stroke %d %d %d %d %d\n", touch.swidth, touch.scolor[0], touch.scolor[1], touch.scolor[2], touch.scolor[3] ); diff --git a/game/client/touch.h b/game/client/touch.h index 80cee87f..aa7a4e82 100644 --- a/game/client/touch.h +++ b/game/client/touch.h @@ -193,6 +193,7 @@ public: float screen_h, screen_w; float forward, side, movecount; float yaw, pitch; + rgba_t gridcolor; private: bool initialized = false;