Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
5.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "ModWizard_TemplateOptions.h"
  7. #include <vgui_controls/DirectorySelectDialog.h>
  8. #include <vgui/IInput.h>
  9. #include <vgui_controls/Button.h>
  10. #include <vgui_controls/WizardPanel.h>
  11. #include <vgui_controls/CheckButton.h>
  12. #include "sdklauncher_main.h"
  13. #include <ctype.h>
  14. #include "CreateModWizard.h"
  15. #include "ModWizard_GetModInfo.h"
  16. #include "ModWizard_CopyFiles.h"
  17. using namespace vgui;
  18. // If the option is disabled, throw this on the front of it.
  19. #define OPTION_DISABLED_PREFIX "//"
  20. // The option strings for the replace
  21. static const char *g_szOptions[] =
  22. {
  23. "#define SDK_USE_TEAMS", //TPOPTION_TEAMS,
  24. "#define SDK_USE_PLAYERCLASSES", //TPOPTION_CLASSES,
  25. "#define SDK_USE_STAMINA", //TPOPTION_STAMINA,
  26. "#define SDK_USE_SPRINTING", //TPOPTION_SPRINTING,
  27. "#define SDK_USE_PRONE", //TPOPTION_PRONE,
  28. "#define SDK_SHOOT_WHILE_SPRINTING", //TPOPTION_SHOOTSPRINTING,
  29. "#define SDK_SHOOT_ON_LADDERS", //TPOPTION_SHOOTLADDERS,
  30. "#define SDK_SHOOT_WHILE_JUMPING", //TPOPTION_SHOOTJUMPING,
  31. };
  32. char *VarArgs( PRINTF_FORMAT_STRING const char *format, ... )
  33. {
  34. va_list argptr;
  35. static char string[1024];
  36. va_start (argptr, format);
  37. Q_vsnprintf(string, sizeof(string), format,argptr);
  38. va_end (argptr);
  39. return string;
  40. }
  41. CModWizardSubPanel_TemplateOptions::CModWizardSubPanel_TemplateOptions( Panel *parent, const char *panelName )
  42. : BaseClass( parent, panelName )
  43. {
  44. m_pOptionTeams = new CheckButton(this, "OptionTeamsButton", "" );
  45. m_pOptionClasses = new CheckButton( this, "OptionClassesButton", "" );
  46. m_pOptionStamina = new CheckButton( this, "OptionStaminaButton", "" );
  47. m_pOptionSprinting = new CheckButton( this, "OptionSprintingButton", "" );
  48. m_pOptionProne = new CheckButton(this, "OptionProneButton", "" );
  49. m_pOptionShootSprinting = new CheckButton( this, "OptionShootSprintingButton", "" );
  50. m_pOptionShootOnLadders = new CheckButton( this, "OptionShootLaddersButton", "" );
  51. m_pOptionShootJumping = new CheckButton( this, "OptionShootJumpingButton", "" );
  52. LoadControlSettings( "ModWizardSubPanel_TemplateOptions.res");
  53. // Sets everything off
  54. SetDefaultOptions();
  55. }
  56. void CModWizardSubPanel_TemplateOptions::SetDefaultOptions()
  57. {
  58. // default everything to off.
  59. for ( int i = 0;i < TPOPTIONS_TOTAL; i++ )
  60. m_bOptions[i] = false;
  61. if ( m_pOptionTeams )
  62. m_pOptionTeams->SetSelected( false );
  63. if ( m_pOptionClasses )
  64. m_pOptionClasses->SetSelected( false );
  65. if ( m_pOptionStamina )
  66. m_pOptionStamina->SetSelected( false );
  67. if ( m_pOptionSprinting )
  68. m_pOptionSprinting->SetSelected( false );
  69. if ( m_pOptionProne )
  70. m_pOptionProne->SetSelected( false );
  71. if ( m_pOptionShootSprinting )
  72. m_pOptionShootSprinting->SetSelected( false );
  73. if ( m_pOptionShootOnLadders )
  74. m_pOptionShootOnLadders->SetSelected( false );
  75. if ( m_pOptionShootJumping )
  76. m_pOptionShootJumping->SetSelected( false );
  77. }
  78. char *CModWizardSubPanel_TemplateOptions::GetOption( int optionType )
  79. {
  80. // Option is enabled, just pass the string back unaltered.
  81. if ( true == m_bOptions[optionType] )
  82. {
  83. return (char*)g_szOptions[optionType];
  84. }
  85. else
  86. {
  87. // Option is disabled, tack the comment '//' infront of the string, must strdup this
  88. return strdup(VarArgs( "//%s", g_szOptions[optionType] ));
  89. }
  90. }
  91. // Update all the options based on the check boxes.
  92. void CModWizardSubPanel_TemplateOptions::UpdateOptions()
  93. {
  94. if ( m_pOptionTeams && m_pOptionTeams->IsSelected() )
  95. m_bOptions[TPOPTION_TEAMS] = true;
  96. if ( m_pOptionClasses && m_pOptionClasses->IsSelected() )
  97. m_bOptions[TPOPTION_CLASSES] = true;
  98. if ( m_pOptionStamina && m_pOptionStamina->IsSelected() )
  99. m_bOptions[TPOPTION_STAMINA] = true;
  100. // if sprinting is enabled, so is stamina no matter what.
  101. if ( m_pOptionSprinting && m_pOptionSprinting->IsSelected() )
  102. {
  103. m_bOptions[TPOPTION_SPRINTING] = true;
  104. m_bOptions[TPOPTION_STAMINA] = true;
  105. }
  106. if ( m_pOptionProne && m_pOptionProne->IsSelected() )
  107. m_bOptions[TPOPTION_PRONE] = true;
  108. if ( m_pOptionShootSprinting && m_pOptionShootSprinting->IsSelected() )
  109. m_bOptions[TPOPTION_SHOOTSPRINTING] = true;
  110. if ( m_pOptionShootOnLadders && m_pOptionShootOnLadders->IsSelected() )
  111. m_bOptions[TPOPTION_SHOOTLADDERS] = true;
  112. if ( m_pOptionShootJumping && m_pOptionShootJumping->IsSelected() )
  113. m_bOptions[TPOPTION_SHOOTJUMPING] = true;
  114. }
  115. WizardSubPanel *CModWizardSubPanel_TemplateOptions::GetNextSubPanel()
  116. {
  117. return dynamic_cast<WizardSubPanel *>(GetWizardPanel()->FindChildByName("CModWizardSubPanel_CopyFiles"));
  118. }
  119. void CModWizardSubPanel_TemplateOptions::PerformLayout()
  120. {
  121. BaseClass::PerformLayout();
  122. GetWizardPanel()->SetFinishButtonEnabled(false);
  123. }
  124. void CModWizardSubPanel_TemplateOptions::OnDisplayAsNext()
  125. {
  126. GetWizardPanel()->SetTitle( "#ModWizard_TemplateOptions_Title", true );
  127. }
  128. bool CModWizardSubPanel_TemplateOptions::OnNextButton()
  129. {
  130. // Update all the options
  131. UpdateOptions();
  132. // nothing else needs to be done here
  133. return true;
  134. }
  135. void CModWizardSubPanel_TemplateOptions::OnCommand( const char *command )
  136. {
  137. BaseClass::OnCommand( command );
  138. }