ExportAll.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : G *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/max2w3d/ExportAll.cpp $*
  25. * *
  26. * $Author:: Andre_a $*
  27. * *
  28. * $Modtime:: 10/15/99 2:08p $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * wwExportTreeSettings -- Returns the directory to export, and recursive flag. *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. /*
  37. ** ExportAll.cpp - Implements wwExportTreeSettings, which presents the user with a dialog
  38. ** to allow them to choose which directory they want to export, and whether they want to
  39. ** export all subdirectories as well. These settings are then passed back so that a script
  40. ** can go through the directory (and maybe the subdirectories) and export all .max files
  41. ** it finds.
  42. */
  43. #include "ExportAllDlg.h"
  44. #undef STRICT
  45. #include <MaxScrpt.h>
  46. #include <Arrays.h>
  47. #include <Strings.h>
  48. #include <definsfn.h>
  49. /*
  50. ** Let MAXScript know we're implementing new built-in functions.
  51. */
  52. def_visible_primitive(export_tree_settings, "wwExportTreeSettings");
  53. /***********************************************************************************************
  54. * export_tree_settings_cf - Returns the directory to export, and recursive flag. *
  55. * *
  56. * wwExportTreeSettings - Usage: wwExportTreeSettings #(<initial path>, <recursive>) *
  57. * *
  58. * INPUT: A MaxScript array containing two values: *
  59. * initial_path (string) - the initial export directory *
  60. * recursive (bool) - the initial recursive setting *
  61. * *
  62. * OUTPUT: An array of the same format containing the values the user chose. *
  63. * *
  64. * WARNINGS: *
  65. * *
  66. * HISTORY: *
  67. * 10/4/1999 AJA : Created. *
  68. *=============================================================================================*/
  69. Value * export_tree_settings_cf (Value **arg_list, int count)
  70. {
  71. // We want an array as an argument
  72. check_arg_count("wwExportAll", 1, count);
  73. type_check(arg_list[0], Array, "Parameter array");
  74. // Grab the two values out of the array.
  75. // First value is a string whose value is the initial value for the directory.
  76. // Second value is a bool, true for a recursive export.
  77. ExportAllDlg dlg(MAXScript_interface);
  78. Array *args = (Array*)(arg_list[0]);
  79. char *temp = (args->get(1))->to_string();
  80. int len = strlen(temp);
  81. if (len < MAX_PATH)
  82. strcpy(dlg.m_Directory, temp);
  83. else
  84. {
  85. strncpy(dlg.m_Directory, temp, MAX_PATH-1);
  86. dlg.m_Directory[MAX_PATH-1] = 0;
  87. }
  88. dlg.m_Recursive = (args->get(2))->to_bool();
  89. // Show the dialog to let the user change the settings.
  90. if (dlg.DoModal() == IDCANCEL)
  91. return &undefined;
  92. // Create the array we will return to MaxScript.
  93. one_typed_value_local(Array *result);
  94. vl.result = new Array(2);
  95. vl.result->append(new String(dlg.m_Directory));
  96. if (dlg.m_Recursive)
  97. vl.result->append(&true_value);
  98. else
  99. vl.result->append(&false_value);
  100. // Return the new values.
  101. return_value(vl.result);
  102. }