virtual void do_validate() { bool ok= true; if (_left_file.get_active()) { if (!g_file_test(_left_filename.get_string_value().c_str(), G_FILE_TEST_IS_REGULAR)) ok= false; } if (!ok) { if (_form) _form->set_problem("Select Left File"); return; } if (_right_file.get_active()) { if (!g_file_test(_right_filename.get_string_value().c_str(), G_FILE_TEST_IS_REGULAR)) ok= false; } if (!ok) { if (_form) _form->set_problem("Select Right File"); return; } if (_form) _form->set_problem(""); }
//----------------------------------------------------------------------------- // Purpose: Adds lines to the text entry every second. //----------------------------------------------------------------------------- void TextEntryDemo4::OnTick() { if (m_iTimeoutTime) { int currentTime = system()->GetTimeMillis(); // Check for timeout if (currentTime > m_iTimeoutTime) { char buf[125]; sprintf (buf, "Additional Text %d\n", m_iTimeoutTime); // Move to the end of the history before we add some new text. // Its important to call this and explicitly move to the // correct position in case someone clicked in // the window (this moves the cursor) // If you comment out this line and rerun you will see // that if you click in the text window additional // text will be added where you clicked. m_pTextEntry->DoGotoTextEnd(); // Add some text to the text entry window m_pTextEntry->DoInsertString(buf); // Timed out, make a new timeout time m_iTimeoutTime = system()->GetTimeMillis() + TIMEOUT; } } }
virtual void OnCommand( const char *command ) { if ( !Q_strnicmp( command, "register", 8 ) ) { if ( steamapicontext && steamapicontext->SteamFriends() ) { steamapicontext->SteamFriends()->ActivateGameOverlayToWebPage( "http://www.youtube.com/create_account?next=/" ); } } else if ( !Q_strnicmp( command, "confirm", 7 ) ) { TextEntry *pTextEntryUserName = dynamic_cast< TextEntry * >( FindChildByName( "UserNameTextEntry" ) ); TextEntry *pTextEntryPassword = dynamic_cast< TextEntry * >( FindChildByName( "PasswordTextEntry" ) ); if ( pTextEntryUserName && pTextEntryPassword ) { char szUserName[256]; pTextEntryUserName->GetText( szUserName, sizeof( szUserName ) ); char szPassword[256]; pTextEntryPassword->GetText( szPassword, sizeof( szPassword ) ); youtube_username.SetValue( szUserName ); Login( szUserName, szPassword ); } return; } BaseClass::OnCommand( command ); }
static int l_attr_text(lua_State *l) { TextEntry *te = LuaObject<UI::TextEntry>::CheckFromLua(1); const std::string &text(te->GetText()); lua_pushlstring(l, text.c_str(), text.size()); return 1; }
static int l_set_color(lua_State *l) { TextEntry *te = LuaObject<UI::TextEntry>::CheckFromLua(1); Color c = Color::FromLuaTable(l, 2); te->SetColor(c); lua_pushvalue(l, 1); return 1; }
//----------------------------------------------------------------------------- // Purpose: Sets the text of a control by name //----------------------------------------------------------------------------- void CDialogGameInfo::SetControlText(const char *textEntryName, const char *text) { TextEntry *entry = dynamic_cast<TextEntry *>(FindChildByName(textEntryName)); if (entry) { entry->SetText(text); } }
//----------------------------------------------------------------------------- // Purpose: Sets the text of a control by name //----------------------------------------------------------------------------- void CConfigPanel::SetControlText(const char *textEntryName, const char *text) { TextEntry *entry = dynamic_cast<TextEntry *>(FindChildByName(textEntryName)); if (entry) { entry->SetText(text); } }
static int l_set_text(lua_State *l) { TextEntry *te = LuaObject<UI::TextEntry>::CheckFromLua(1); std::string new_text; pi_lua_generic_pull(l, 2, new_text); te->SetText(new_text); lua_pushvalue(l, 1); return 1; }
virtual void ApplySchemeSettings( vgui::IScheme *pScheme ) { BaseClass::ApplySchemeSettings( pScheme ); TextEntry *pTextEntryUserName = dynamic_cast< TextEntry * >( FindChildByName( "UserNameTextEntry" ) ); if ( pTextEntryUserName ) { pTextEntryUserName->SetText( "" ); pTextEntryUserName->InsertString( youtube_username.GetString() ); } }
//----------------------------------------------------------------------------- // Purpose: // Input : *panelName - // *valueName - //----------------------------------------------------------------------------- void CDialogUserInfo::SetChildText(const char *panelName, const char *valueName) { TextEntry *text = dynamic_cast<TextEntry *>(FindChildByName(panelName)); if (text) { char buf[512]; strncpy(buf, GetDoc()->GetBuddy(m_iUserID)->Data()->GetString(valueName, ""), sizeof(buf) - 1); buf[511] = 0; text->SetText(buf); } }
//----------------------------------------------------------------------------- // Purpose: When the enter key is pressed we clear the textentry. // To add a newline use ctrl-return. //----------------------------------------------------------------------------- void TextEntryDemo5::OnKeyCodeTyped(KeyCode code) { if (code == KEY_ENTER) { m_pTextEntry->SetText(""); } DemoPage::OnKeyCodeTyped(code); }
void right_changed() { if (_right_model.get_active()) { _left_model.set_enabled(false); _right_filebox_b.set_enabled(false); _right_filename.set_enabled(false); } else if (_right_db.get_active()) { _left_model.set_enabled(true); _right_filebox_b.set_enabled(false); _right_filename.set_enabled(false); } else { _left_model.set_enabled(true); _right_filebox_b.set_enabled(true); _right_filename.set_enabled(true); } validate(); }
//----------------------------------------------------------------------------- // Purpose: Creates all the controls in the game options list //----------------------------------------------------------------------------- void CCreateMultiplayerGameGameplayPage::LoadGameOptionsList() { // destroy any existing controls mpcontrol_t *p, *n; p = m_pList; while ( p ) { n = p->next; // delete p->pControl; delete p->pPrompt; delete p; p = n; } m_pList = NULL; // Go through desciption creating controls CScriptObject *pObj; pObj = m_pDescription->pObjList; mpcontrol_t *pCtrl; CheckButton *pBox; TextEntry *pEdit; ComboBox *pCombo; CScriptListItem *pListItem; Panel *objParent = m_pOptionsList; while ( pObj ) { pCtrl = new mpcontrol_t( objParent, "mpcontrol_t" ); pCtrl->type = pObj->type; switch ( pCtrl->type ) { case O_BOOL: pBox = new CheckButton( pCtrl, "DescCheckButton", pObj->prompt ); pBox->SetSelected( pObj->fdefValue != 0.0f ? true : false ); pCtrl->pControl = (Panel *)pBox; break; case O_STRING: case O_NUMBER: pEdit = new TextEntry( pCtrl, "DescTextEntry"); pEdit->InsertString(pObj->defValue); pCtrl->pControl = (Panel *)pEdit; break; case O_LIST: pCombo = new ComboBox( pCtrl, "DescComboBox", 5, false ); pListItem = pObj->pListItems; while ( pListItem ) { pCombo->AddItem(pListItem->szItemText, NULL); pListItem = pListItem->pNext; } pCombo->ActivateItemByRow((int)pObj->fdefValue); pCtrl->pControl = (Panel *)pCombo; break; default: break; } if ( pCtrl->type != O_BOOL ) { pCtrl->pPrompt = new vgui::Label( pCtrl, "DescLabel", "" ); pCtrl->pPrompt->SetContentAlignment( vgui::Label::a_west ); pCtrl->pPrompt->SetTextInset( 5, 0 ); pCtrl->pPrompt->SetText( pObj->prompt ); } pCtrl->pScrObj = pObj; pCtrl->SetSize( 100, 28 ); //pCtrl->SetBorder( scheme()->GetBorder(1, "DepressedButtonBorder") ); m_pOptionsList->AddItem( pCtrl ); // Link it in if ( !m_pList ) { m_pList = pCtrl; pCtrl->next = NULL; } else { mpcontrol_t *p; p = m_pList; while ( p ) { if ( !p->next ) { p->next = pCtrl; pCtrl->next = NULL; break; } p = p->next; } } pObj = pObj->pNext; } }
//----------------------------------------------------------------------------- // Purpose: applies all the values in the page //----------------------------------------------------------------------------- void CCreateMultiplayerGameGameplayPage::GatherCurrentValues() { if ( !m_pDescription ) return; // OK CheckButton *pBox; TextEntry *pEdit; ComboBox *pCombo; mpcontrol_t *pList; CScriptObject *pObj; CScriptListItem *pItem; char szValue[256]; char strValue[ 256 ]; pList = m_pList; while ( pList ) { pObj = pList->pScrObj; if ( !pList->pControl ) { pObj->SetCurValue( pObj->defValue ); pList = pList->next; continue; } switch ( pObj->type ) { case O_BOOL: pBox = (CheckButton *)pList->pControl; sprintf( szValue, "%s", pBox->IsSelected() ? "1" : "0" ); break; case O_NUMBER: pEdit = ( TextEntry * )pList->pControl; pEdit->GetText( strValue, sizeof( strValue ) ); sprintf( szValue, "%s", strValue ); break; case O_STRING: pEdit = ( TextEntry * )pList->pControl; pEdit->GetText( strValue, sizeof( strValue ) ); sprintf( szValue, "%s", strValue ); break; case O_LIST: pCombo = ( ComboBox *)pList->pControl; pCombo->GetText( strValue, sizeof( strValue ) ); pItem = pObj->pListItems; int n = (int)pObj->fdefValue; while ( pItem ) { if ( !stricmp( pItem->szItemText, strValue ) ) { break; } pItem = pItem->pNext; } if ( pItem ) { sprintf( szValue, "%s", pItem->szValue ); } else //Couln't find index { sprintf( szValue, "%s", pObj->defValue ); } break; } // Remove double quotes and % characters UTIL_StripInvalidCharacters( szValue ); strcpy( strValue, szValue ); pObj->SetCurValue( strValue ); pList = pList->next; } }
void CSheet_Array::UpdateArrayBlocks( const int &dest_x, const int &dest_y ) { int old_x, old_y; old_x = old_y = 0; char ***oldEntires = BuildStringSheet( old_x, old_y ); for ( int y = 0; y < old_y; y++ ) { //for ( int x = 0; x < old_x; x++ ) m_hArray_Y_Major[y]->Purge(); delete m_hArray_Y_Major[y]; } m_hArray_Y_Major.Purge(); int iCurItem = m_pArrayPanel->FirstItem(); while ( iCurItem != m_pArrayPanel->InvalidItemID() ) { Panel *pA = m_pArrayPanel->GetItemLabel( iCurItem ); Panel *pB = m_pArrayPanel->GetItemPanel( iCurItem ); if ( pA != NULL ) pA->MarkForDeletion(); if ( pB != NULL ) pB->MarkForDeletion(); iCurItem = m_pArrayPanel->NextItem( iCurItem ); } m_pArrayPanel->DeleteAllItems(); m_pArrayPanel->RemoveAll(); for ( int y = 0; y < dest_y; y++ ) { CUtlVector< TextEntry* > *cur = new CUtlVector< TextEntry* >; m_hArray_Y_Major.AddToTail( cur ); } m_pArrayPanel->SetNumColumns( dest_y ); for ( int x = 0; x < dest_x; x++ ) { for ( int y = 0; y < dest_y; y++ ) { CUtlVector< TextEntry* > *cur = m_hArray_Y_Major[y]; TextEntry *pEntry = new TextEntry( m_pArrayPanel, "arrayslot" ); pEntry->AddActionSignalTarget( this ); cur->AddToTail( pEntry ); if ( x < old_x && y < old_y && oldEntires != NULL ) { pEntry->SetText( oldEntires[x][y] ); } else pEntry->SetText( "0" ); Label *pHeader = NULL; if ( y == 0 ) pHeader = new Label( m_pArrayPanel, "", VarArgs( "%i:", x ) ); m_pArrayPanel->AddItem( pHeader, pEntry ); pEntry->MakeReadyForUse(); pEntry->InvalidateLayout( true, true ); pEntry->SetBgColor( TOKENCHANNELS_SUPPORTED_COLOR ); } } m_pArrayPanel->SetFirstColumnWidth( 20 ); if ( oldEntires != NULL ) DestroyStringSheet( oldEntires, old_x, old_y ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFOptionsAdvancedPanel::CreateControls() { BaseClass::CreateControls(); // Go through desciption creating controls CScriptObject *pObj; pObj = m_pDescription->pObjList; mpcontrol_t *pCtrl; CTFAdvCheckButton *pBox; TextEntry *pEdit; ComboBox *pCombo; CTFAdvSlider *pScroll; CTFAdvButton *pTitle; CScriptListItem *pListItem; Panel *objParent = m_pListPanel; while (pObj) { //Msg("\nAdded: %s %s %f %f %i\n", pObj->prompt, pObj->cvarname, pObj->fcurValue, pObj->fdefValue, pObj->type); if (pObj->type == O_OBSOLETE) { pObj = pObj->pNext; continue; } pCtrl = new mpcontrol_t(objParent, "mpcontrol_t"); pCtrl->type = pObj->type; switch (pCtrl->type) { case O_BOOL: pBox = new CTFAdvCheckButton(pCtrl, "DescCheckButton", pObj->prompt); pBox->SetSelected(pObj->fdefValue != 0.0f ? true : false); pBox->SetCommandString(pObj->cvarname); pBox->GetButton()->SetFontByString(m_pListPanel->GetFontString()); if (pObj->tooltip[0] != '\0') { wchar_t *pText = g_pVGuiLocalize->Find(pObj->tooltip); if (pText != NULL) { char pszToolTipLocal[256]; wcstombs(pszToolTipLocal, pText, sizeof(pszToolTipLocal)); pBox->SetToolTip(pszToolTipLocal); } else { pBox->SetToolTip(pObj->tooltip); } } pCtrl->pControl = (Panel *)pBox; break; case O_STRING: case O_NUMBER: pEdit = new TextEntry(pCtrl, "DescTextEntry"); pEdit->InsertString(pObj->defValue); pCtrl->pControl = (Panel *)pEdit; break; case O_SLIDER: pScroll = new CTFAdvSlider(pCtrl, "DescScrollEntry", pObj->prompt); pScroll->SetValue(pObj->fdefValue); pScroll->SetCommandString(pObj->cvarname); pScroll->SetMinMax(pObj->fMin, pObj->fMax); pScroll->GetButton()->SetFontByString(m_pListPanel->GetFontString()); pCtrl->pControl = (Panel *)pScroll; break; case O_LIST: pCombo = new ComboBox(pCtrl, "DescComboBox", 5, false); pListItem = pObj->pListItems; while (pListItem) { pCombo->AddItem(pListItem->szItemText, NULL); pListItem = pListItem->pNext; } pCombo->ActivateItemByRow((int)pObj->fdefValue); pCtrl->pControl = (Panel *)pCombo; break; case O_CATEGORY: pTitle = new CTFAdvButton(pCtrl, "DescTextTitle", pObj->prompt); pTitle->SetEnabled(false); pTitle->SetBorderByString("AdvSettingsTitleBorder"); pTitle->SetBorderVisible(true); pTitle->GetButton()->SetFontByString("MenuSmallFont"); pCtrl->pControl = (Panel *)pTitle; break; default: break; } if (pCtrl->type != O_BOOL && pCtrl->type != O_SLIDER && pCtrl->type != O_CATEGORY) { pCtrl->pPrompt = new vgui::Label(pCtrl, "DescLabel", ""); pCtrl->pPrompt->SetFont(m_pListPanel->GetFont()); pCtrl->pPrompt->SetContentAlignment(vgui::Label::a_west); pCtrl->pPrompt->SetTextInset(5, 0); pCtrl->pPrompt->SetText(pObj->prompt); } pCtrl->pScrObj = pObj; int h = m_pListPanel->GetTall() / 13.0; //(float)GetParent()->GetTall() / 15.0; pCtrl->SetSize(800, h); //pCtrl->SetBorder( scheme()->GetBorder(1, "DepressedButtonBorder") ); m_pListPanel->AddItem(pCtrl); // Link it in if (!m_pList) { m_pList = pCtrl; pCtrl->next = NULL; } else { mpcontrol_t *p; p = m_pList; while (p) { if (!p->next) { p->next = pCtrl; pCtrl->next = NULL; break; } p = p->next; } } pObj = pObj->pNext; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFOptionsAdvancedPanel::GatherCurrentValues() { if (!m_pDescription) return; // OK CTFAdvCheckButton *pBox; TextEntry *pEdit; ComboBox *pCombo; CTFAdvSlider *pScroll; mpcontrol_t *pList; CScriptObject *pObj; CScriptListItem *pItem; char szValue[256]; char strValue[256]; int iValue; pList = m_pList; while (pList) { pObj = pList->pScrObj; if (!pList->pControl) { pObj->SetCurValue(pObj->defValue); pList = pList->next; continue; } switch (pObj->type) { case O_BOOL: pBox = (CTFAdvCheckButton *)pList->pControl; sprintf(szValue, "%s", pBox->IsSelected() ? "1" : "0"); break; case O_NUMBER: pEdit = (TextEntry *)pList->pControl; pEdit->GetText(strValue, sizeof(strValue)); sprintf(szValue, "%s", strValue); break; case O_SLIDER: pScroll = (CTFAdvSlider *)pList->pControl; iValue = pScroll->GetValue(); sprintf(szValue, "%i", iValue); break; case O_STRING: pEdit = (TextEntry *)pList->pControl; pEdit->GetText(strValue, sizeof(strValue)); sprintf(szValue, "%s", strValue); break; case O_CATEGORY: break; case O_LIST: pCombo = (ComboBox *)pList->pControl; pCombo->GetText( strValue, sizeof( strValue ) ); int activeItem = pCombo->GetActiveItem(); pItem = pObj->pListItems; // int n = (int)pObj->fdefValue; while (pItem) { if (!activeItem--) break; pItem = pItem->pNext; } if (pItem) { sprintf(szValue, "%s", pItem->szValue); } else // Couln't find index { //assert(!("Couldn't find string in list, using default value")); sprintf(szValue, "%s", pObj->defValue); } break; } // Remove double quotes and % characters UTIL_StripInvalidCharacters(szValue, sizeof(szValue)); strcpy(strValue, szValue); pObj->SetCurValue(strValue); pList = pList->next; } }
//============================================================================= void Multiplayer::OnCommand(const char *command) { if( Q_stricmp( "#GameUI_Headphones", command ) == 0 ) { CGameUIConVarRef snd_surround_speakers("Snd_Surround_Speakers"); snd_surround_speakers.SetValue( "0" ); } else if ( char const *sz = StringAfterPrefix( command, "#GameUI_DownloadFilter_" ) ) { CGameUIConVarRef cl_downloadfilter( "cl_downloadfilter" ); cl_downloadfilter.SetValue( sz ); } else if ( char const *sz = StringAfterPrefix( command, "ColorBlind" ) ) { CGameUIConVarRef cl_colorblind( "cl_colorblind" ); cl_colorblind.SetValue( sz ); } else if ( char const *sz = StringAfterPrefix( command, "GameInstructor" ) ) { CGameUIConVarRef gameinstructor_enable( "gameinstructor_enable" ); gameinstructor_enable.SetValue( !Q_stricmp( sz, "Enabled" ) ); } else if ( char const *sz = StringAfterPrefix( command, "AllowFreeLook" ) ) { CGameUIConVarRef spec_allowroaming( "spec_allowroaming" ); spec_allowroaming.SetValue( !Q_stricmp( sz, "Enabled" ) ); } else if ( char const *sz = StringAfterPrefix( command, "MpLanGames" ) ) { CGameUIConVarRef net_allow_multicast( "net_allow_multicast" ); net_allow_multicast.SetValue( !Q_stricmp( sz, "Enabled" ) ); } else if ( StringHasPrefix( command, "_spraypaint" ) ) { int iCommandNumberPosition = Q_strlen( MULTIPLAYER_SPRAYPAINT_COMMAND_PREFIX ); int iLogo = clamp( command[ iCommandNumberPosition ] - '0', 0, m_nNumSpraypaintLogos - 1 ); if ( m_nSpraypaint[ iLogo ].m_bCustom && m_nSpraypaint[ iLogo ].m_szFilename[ 0 ] == '\0' ) { // Select a file from the custom directory! if ( m_hSelectSprayDialog ) { // Always start fresh so the directory refreshes m_hSelectSprayDialog->DeletePanel(); m_hSelectSprayDialog = NULL; } m_hSelectSprayDialog = new FileOpenDialog(this, "#L4D360UI_Multiplayer_Cutsom_Logo", true); m_hSelectSprayDialog->SetProportional( false ); m_hSelectSprayDialog->SetDeleteSelfOnClose( false ); m_hSelectSprayDialog->AddFilter("*.vtf", "*.vtf", true); m_hSelectSprayDialog->AddActionSignalTarget(this); char szCustomSprayDir[ MAX_PATH ]; Q_snprintf( szCustomSprayDir, sizeof( szCustomSprayDir ), "%s/" MULTIPLAYER_SPRAY_FOLDER MULTIPLAYER_CUSTOM_SPRAY_FOLDER, engine->GetGameDirectory() ); m_hSelectSprayDialog->SetStartDirectoryContext( "SelectCustomLogo", szCustomSprayDir ); m_hSelectSprayDialog->DoModal(false); m_hSelectSprayDialog->Activate(); // Hide directory buttons m_hSelectSprayDialog->SetControlVisible( "FolderUpButton", false ); m_hSelectSprayDialog->SetControlVisible( "NewFolderButton", false ); m_hSelectSprayDialog->SetControlVisible( "OpenInExplorerButton", false ); m_hSelectSprayDialog->SetControlVisible( "LookInLabel", false ); m_hSelectSprayDialog->SetControlVisible( "FullPathEdit", false ); m_hSelectSprayDialog->SetControlVisible( "FileNameLabel", false ); for ( int i = 0; i < m_hSelectSprayDialog->GetChildCount(); ++i ) { // Need to hide text entry box so they can't manually type ".." and go back a dir TextEntry *pTextEntry = dynamic_cast<TextEntry*>( m_hSelectSprayDialog->GetChild( i ) ); if ( pTextEntry && !dynamic_cast<ComboBox*>( pTextEntry ) ) { pTextEntry->SetVisible( false ); } } } else { char *pchCustomPath = ( ( m_nSpraypaint[ iLogo ].m_bCustom ) ? ( MULTIPLAYER_CUSTOM_SPRAY_FOLDER ) : ( "" ) ); char rootFilename[MAX_PATH]; Q_snprintf( rootFilename, sizeof(rootFilename), MULTIPLAYER_SPRAY_FOLDER "%s%s.vtf", pchCustomPath, m_nSpraypaint[ iLogo ].m_szFilename ); CGameUIConVarRef cl_logofile( "cl_logofile", true ); cl_logofile.SetValue( rootFilename ); RemapLogo( m_nSpraypaint[ iLogo ].m_szFilename, m_pSprayLogo, pchCustomPath ); // Clear out the custom image's filename so they will be forced to reselect for ( int i = 0; i < MAX_SPRAYPAINT_LOGOS; ++i ) { if ( m_nSpraypaint[ iLogo ].m_bCustom ) { m_nSpraypaint[ iLogo ].m_szFilename[ 0 ] = '\0'; } } } } else if( Q_stricmp( "ImportSprayImage", command ) == 0 ) { FlyoutMenu::CloseActiveMenu(); if ( m_hImportSprayDialog == NULL) { m_hImportSprayDialog = new FileOpenDialog(this, "#GameUI_ImportSprayImage", true); m_hImportSprayDialog->SetProportional( false ); m_hImportSprayDialog->SetDeleteSelfOnClose( false ); m_hImportSprayDialog->AddFilter("*.tga,*.jpg,*.bmp,*.vtf", "#GameUI_All_Images", true); m_hImportSprayDialog->AddFilter("*.tga", "#GameUI_TGA_Images", false); m_hImportSprayDialog->AddFilter("*.jpg", "#GameUI_JPEG_Images", false); m_hImportSprayDialog->AddFilter("*.bmp", "#GameUI_BMP_Images", false); m_hImportSprayDialog->AddFilter("*.vtf", "#GameUI_VTF_Images", false); m_hImportSprayDialog->AddActionSignalTarget(this); char szGameDir[ MAX_PATH ]; Q_snprintf( szGameDir, sizeof( szGameDir ), "%s/", engine->GetGameDirectory() ); m_hImportSprayDialog->SetStartDirectoryContext( "ImportCustomLogo", szGameDir ); } m_hImportSprayDialog->DoModal(false); m_hImportSprayDialog->Activate(); } else if( Q_stricmp( "Back", command ) == 0 ) { OnKeyCodePressed( ButtonCodeToJoystickButtonCode( KEY_XBUTTON_B, CBaseModPanel::GetSingleton().GetLastActiveUserId() ) ); } else if ( !Q_stricmp( command, "#L4D360UI_Gore_High" ) ) { CGameUIConVarRef z_wound_client_disabled( "z_wound_client_disabled" ); z_wound_client_disabled.SetValue( 0 ); } else if ( !Q_stricmp( command, "#L4D360UI_Gore_Low" ) ) { CGameUIConVarRef z_wound_client_disabled( "z_wound_client_disabled" ); z_wound_client_disabled.SetValue( 1 ); } else { BaseClass::OnCommand( command ); } }
Page1(WizardForm *form) : WizardPage(form, "pg1"), _left_panel(true), _left_vbox(false), _left_filebox(true), _right_panel(true), _right_vbox(false), _right_filebox(true), _top_level(true) { set_title("Catalog synchronization"); set_subtitle("Select your catalog objects for synchronization"); add(&_top_level, false, true); _left_panel.set_title("Source for the Left Catalog"); _left_panel.add(&_left_vbox); _left_model.set_text("Model Schemata"); _left_db.set_text("Live Database Server"); _left_file.set_text("SQL Script File"); _left_model.signal_toggled().connect(sigc::mem_fun(this, &Page1::left_changed)); _left_db.signal_toggled().connect(sigc::mem_fun(this, &Page1::left_changed)); _left_file.signal_toggled().connect(sigc::mem_fun(this, &Page1::left_changed)); _left_vbox.set_spacing(8); _left_vbox.set_padding(8); _left_filebox.set_spacing(4); _left_filebox_l.set_text("File Name:"); _left_filebox_b.set_text("Browse..."); _left_filebox_b.set_size(100, -1); _left_filename.set_size(30, -1); _left_filebox.add(&_left_filebox_l, false, true); _left_filebox.add(&_left_filename, true, true); _left_filebox.add(&_left_filebox_b, false, false); enable_file_browsing(&_left_filename, &_left_filebox_b, mforms::OpenFile); _left_vbox.add(&_left_model, false, true); _left_vbox.add(&_left_db, false, true); _left_vbox.add(&_left_file, false, true); _left_vbox.add(&_left_filebox, false, true); _right_panel.set_title("Source for the Right Catalog"); _right_panel.add(&_right_vbox); _right_model.set_text("Model Schemata"); _right_db.set_text("Live Database Server"); _right_file.set_text("SQL Script File"); _right_model.signal_toggled().connect(sigc::mem_fun(this, &Page1::right_changed)); _right_db.signal_toggled().connect(sigc::mem_fun(this, &Page1::right_changed)); _right_file.signal_toggled().connect(sigc::mem_fun(this, &Page1::right_changed)); _right_filebox.set_spacing(4); _right_filebox_l.set_text("File Name:"); _right_filebox_b.set_text("Browse..."); _right_filebox_b.set_size(100, -1); _right_filename.set_size(30, -1); _right_filebox.add(&_right_filebox_l, false, true); _right_filebox.add(&_right_filename, true, true); _right_filebox.add(&_right_filebox_b, false, false); enable_file_browsing(&_right_filename, &_right_filebox_b, mforms::OpenFile); _right_vbox.set_spacing(8); _right_vbox.set_padding(8); _right_vbox.add(&_right_model, false, true); _right_vbox.add(&_right_db, false, true); _right_vbox.add(&_right_file, false, true); _right_vbox.add(&_right_filebox, false, true); _right_file.set_active(true); _top_level.set_homogeneous(true); _top_level.add(&_left_panel, false, true); _top_level.add(&_right_panel, false, true); _top_level.set_padding(12); _top_level.set_spacing(12); }
//----------------------------------------------------------------------------- // Purpose: sets up the current control to edit //----------------------------------------------------------------------------- void BuildModeDialog::SetActiveControl(Panel *controlToEdit) { if (m_pCurrentPanel == controlToEdit) { // it's already set, so just update the property data and quit if (m_pCurrentPanel) { UpdateControlData(m_pCurrentPanel); } return; } // reset the data m_pCurrentPanel = controlToEdit; RemoveAllControls(); m_pPanelList->m_pControls->MoveScrollBarToTop(); if (!m_pCurrentPanel) { m_pStatusLabel->SetText("[nothing currently selected]"); m_pStatusLabel->SetTextColorState(Label::CS_DULL); RemoveAllControls(); return; } // get the control description string const char *controlDesc = m_pCurrentPanel->GetDescription(); // parse out the control description int tabPosition = 1; while (1) { const char *dataType = ParseTokenFromString(&controlDesc); // finish when we have no more tokens if (*dataType == 0) break; // default the data type to a string int datat = TYPE_STRING; if (!stricmp(dataType, "int")) { datat = TYPE_STRING; //!! just for now } else if (!stricmp(dataType, "alignment")) { datat = TYPE_ALIGNMENT; } else if (!stricmp(dataType, "autoresize")) { datat = TYPE_AUTORESIZE; } else if (!stricmp(dataType, "corner")) { datat = TYPE_CORNER; } else if (!stricmp(dataType, "localize")) { datat = TYPE_LOCALIZEDSTRING; } // get the field name const char *fieldName = ParseTokenFromString(&controlDesc); int itemHeight = 18; // build a control & label Label *label = new Label(this, NULL, fieldName); label->SetSize(96, itemHeight); label->SetContentAlignment(Label::a_east); TextEntry *edit = NULL; ComboBox *editCombo = NULL; Button *editButton = NULL; if (datat == TYPE_ALIGNMENT) { // drop-down combo box editCombo = new ComboBox(this, NULL, 9, false); editCombo->AddItem("north-west", NULL); editCombo->AddItem("north", NULL); editCombo->AddItem("north-east", NULL); editCombo->AddItem("west", NULL); editCombo->AddItem("center", NULL); editCombo->AddItem("east", NULL); editCombo->AddItem("south-west", NULL); editCombo->AddItem("south", NULL); editCombo->AddItem("south-east", NULL); edit = editCombo; } else if (datat == TYPE_AUTORESIZE) { // drop-down combo box editCombo = new ComboBox(this, NULL, 4, false); editCombo->AddItem( "0 - no auto-resize", NULL); editCombo->AddItem( "1 - resize right", NULL); editCombo->AddItem( "2 - resize down", NULL); editCombo->AddItem( "3 - down & right", NULL); edit = editCombo; } else if (datat == TYPE_CORNER) { // drop-down combo box editCombo = new ComboBox(this, NULL, 4, false); editCombo->AddItem("0 - top-left", NULL); editCombo->AddItem("1 - top-right", NULL); editCombo->AddItem("2 - bottom-left", NULL); editCombo->AddItem("3 - bottom-right", NULL); edit = editCombo; } else if (datat == TYPE_LOCALIZEDSTRING) { editButton = new Button(this, NULL, "..."); editButton->SetParent(this); editButton->AddActionSignalTarget(this); editButton->SetTabPosition(tabPosition++); editButton->SetTall( itemHeight ); label->SetAssociatedControl(editButton); } else { // normal string edit edit = new CSmallTextEntry(this, NULL); } if (edit) { edit->SetTall( itemHeight ); edit->SetParent(this); edit->AddActionSignalTarget(this); edit->SetTabPosition(tabPosition++); label->SetAssociatedControl(edit); } HFont smallFont = scheme()->GetIScheme( GetScheme() )->GetFont( "DefaultVerySmall" ); if ( label ) { label->SetFont( smallFont ); } if ( edit ) { edit->SetFont( smallFont ); } if ( editCombo ) { editCombo->SetFont( smallFont ); } if ( editButton ) { editButton->SetFont( smallFont ); } // add to our control list m_pPanelList->AddItem(label, edit, editCombo, editButton, fieldName, datat); if ( edit ) { m_pPanelList->m_pControls->AddItem(label, edit); } else { m_pPanelList->m_pControls->AddItem(label, editButton); } } // check and see if the current panel is a Label // iterate through the class hierarchy if ( controlToEdit->IsBuildModeDeletable() ) { m_pDeleteButton->SetEnabled(true); } else { m_pDeleteButton->SetEnabled(false); } // update the property data in the dialog UpdateControlData(m_pCurrentPanel); // set our title if ( m_pBuildGroup->GetResourceName() ) { m_pFileSelectionCombo->SetText(m_pBuildGroup->GetResourceName()); } else { m_pFileSelectionCombo->SetText("[ no resource file associated with dialog ]"); } m_pApplyButton->SetEnabled(false); InvalidateLayout(); Repaint(); }
//----------------------------------------------------------------------------- // Sets up the shader param editbox //----------------------------------------------------------------------------- void CMaterialEditorPanel::PopulateShaderParameters() { Assert( m_nShaderIndex >= 0 ); m_pEditorPanel->RemoveAll(); int nCount = g_pMaterialSystem->GetNumShaderParams(m_nShaderIndex); for (int i = 0; i < nCount; ++i) { const char *pParamName = g_pMaterialSystem->GetShaderParamName(m_nShaderIndex, i); char tempBuf[512]; Q_strncpy( tempBuf, pParamName, 512 ); Q_strnlwr( tempBuf, 512 ); // build a control & label (strip off '$' prefix) Label *pLabel = new Label( this, NULL, tempBuf + 1 ); pLabel->SetSize(128, 24); // Set up the tooltip for this puppy... pLabel->SetTooltipText( g_pMaterialSystem->GetShaderParamHelp(m_nShaderIndex, i) ); // Get at the material var bool bFound; IMaterialVar *pMaterialVar = m_pMaterial->FindVar( pParamName, &bFound ); Assert( bFound ); Panel *pEditPanel; switch( g_pMaterialSystem->GetShaderParamType(m_nShaderIndex, i) ) { case SHADER_PARAM_TYPE_TEXTURE: pEditPanel = new Label( this, NULL, "texture" ); break; case SHADER_PARAM_TYPE_INTEGER: { TextEntry *pTextEntry = new TextEntry(this, "Shader Param Integer"); Q_snprintf( tempBuf, 512, "%d", pMaterialVar->GetIntValue() ); pTextEntry->SetText( tempBuf ); pTextEntry->SetEditable( true ); pEditPanel = pTextEntry; } break; case SHADER_PARAM_TYPE_COLOR: pEditPanel = new Label( this, NULL, "color" ); break; case SHADER_PARAM_TYPE_VEC2: pEditPanel = new Label( this, NULL, "vec2" ); break; case SHADER_PARAM_TYPE_VEC3: pEditPanel = new Label( this, NULL, "vec3" ); break; case SHADER_PARAM_TYPE_FLOAT: { TextEntry *pTextEntry = new TextEntry(this, "Shader Param Float"); Q_snprintf( tempBuf, 512, "%f", pMaterialVar->GetIntValue() ); pTextEntry->SetText( tempBuf ); pTextEntry->SetEditable( true ); pEditPanel = pTextEntry; } break; default: pEditPanel = new Label( this, NULL, "other" ); break; } pEditPanel->SetSize(128, 24); // pEditPanel->SetContentAlignment( Label::a_east ); m_pEditorPanel->AddItem( pLabel, pEditPanel ); } }